Apex Design Code:
<apex:page controller="AddUserController">
<apex:form >
<apex:sectionHeader subtitle="All Books" title="Books" />
<apex:pageBlock >
<apex:PageBlockButtons >
<apex:commandButton action="{!Save}" value="Save"/>
</apex:PageBlockButtons>
<apex:pageBlockSection >
<apex:InputField value="{!users.Name}"/><br/>
<apex:InputField value="{!users.Age}" /><br/>
<apex:InputField value="{!users.Class}" /><br/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Controller Code:
public class AddUserController
{
public User__c users;
public AddUserController()
{
users=new User__c();
}
public User__c getUsers()
{
return users;
}
public PageReference Save()
{
try
{
insert(users);
PageReference pagr= Page.UsersPage;
pagr.setRedirect(true);
return pagr;
}
catch(System.DMLException e)
{
return null;
}
}
}
No comments:
Post a Comment