ads

Wednesday 27 July 2016

Insert Record and Clear Fields value After Save




Controller Code :-


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
public class outputPanelPage {
public contact con_insert{get;set;}

public string msg{get;set;}
public outputPanelPage()
{
 msg= 'Plz Enter the value...';
con_insert=new contact();


}

public void save()
{
  
   insert con_insert;
   con_insert=new contact();
   msg= 'Your Record is saved...';
}
}

VF Code :-


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<apex:page controller="outputPanelPage">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="SAVE" action="{!save}"/>

</apex:pageBlockButtons>

<apex:pageBlockSection columns="1">

<apex:inputField value="{!con_insert.lastname}"/>
<apex:inputField value="{!con_insert.AssistantName}"/>
<apex:inputField value="{!con_insert.Birthdate}"/>

</apex:pageBlockSection>


{!msg}


</apex:pageBlock>

</apex:form>
  
</apex:page>

Output Screen :-

             Screen 1 :- Before Save

           
         

              Screen 2 :- After Save











No comments:

Post a Comment