ads

Thursday 28 July 2016

Redirect From One Visulforce Page to Another



Controller Code For First VF Page  :-


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
public class insertRecords{

public account accinsert{get; set;}

public insertRecords()
    {

    accinsert=new account();

    }

    public pagereference save()
    {
        insert accinsert;
        accinsert =new account();
        Pagereference page=new Pagereference('/apex/savemsg');
        Page.setredirect(true);
        return page;
    }
    

}

Visualforce Page Code For First VF Page :-


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
<apex:page controller="insertRecords">
<apex:form >
  <apex:pageBlock >
  <apex:pageBlockButtons >
  <apex:commandButton action="{!save}" value="Save"/>
  </apex:pageBlockButtons>
   <apex:pageBlockSection >
  <apex:inputField value="{!accinsert.name}"/>
   <apex:inputField value="{!accinsert.phone}"/>
    <apex:inputField value="{!accinsert.type}"/>
   </apex:pageBlockSection>
  </apex:pageBlock>
  </apex:form>
</apex:page>

OutPut Screen For First VF Page :-






Visualforce Page Code For Second VF Page :-



1
2
3
4
5
<apex:page >
<apex:pageBlock >
 Your record is saved...
 </apex:pageBlock>
</apex:page>



OutPut Screen For Second VF Page :-


No comments:

Post a Comment