VF page is just page where you are define how many information you would like to have in page, custom controller is just apex class where you define which logic will be behind the VF page.
For creating custom controller go to: 1. Setup -> Develop -> Apex Class 2. Create new one and click Save 3. Paste this code:
public class MyController {
private final Account account;
public MyController() {
account = [SELECT Id, Name, Site FROM Account
WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
}
public Account getAccount() {
return account;
}
public PageReference save() {
update account;
return null;
}
}
Then create your first VF page: 1.Set in your user Development mode to true a. Setup-> Manage users-> Users b. edit c. Check tu true in "Development Mode" 2.For example, if you want to create a page called “myController” and your Salesforce organization uses na3.salesforce.com, enter http://na3.salesforce.com/apex/myController. 3.Paste this code to VF
<apex:page controller="myController" tabStyle="Account">
<apex:form>
<apex:pageBlock title="Congratulations {!$User.FirstName}">
You belong to Account Name: <apex:inputField value="{!account.name}"/>
<apex:commandButton action="{!save}" value="save"/>
</apex:pageBlock>
</apex:form>
</apex:page>
public with sharing class AccountClass{
public Account a;
public AccountClass(){
a=new Account();
}
public pagereference save(){
insert a;
PageReference pr=new PageReference(('https://ap1.salesforce.com/'+a.Id));
return pr;
}
}
Hope this link will help you to understand custom controller.
Link - https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_custom.htm
Thanks,
Have a great day ahead,Let the Force be with you!
Please mark this as best answer if it helps you.
Here is same question and you will get your answer.
https://developer.salesforce.com/forums/?id=906F000000092Z0IAI
-Thanks
Ashlekh Gera
VF page is just page where you are define how many information you would like to have in page, custom controller is just apex class where you define which logic will be behind the VF page.
For creating custom controller go to:
1. Setup -> Develop -> Apex Class
2. Create new one and click Save
3. Paste this code:
Then create your first VF page:
1.Set in your user Development mode to true
a. Setup-> Manage users-> Users
b. edit
c. Check tu true in "Development Mode"
2.For example, if you want to create a page called “myController” and your Salesforce organization uses na3.salesforce.com, enter http://na3.salesforce.com/apex/myController.
3.Paste this code to VF 4. Click Save
Controller:
VisualForce Page:
Hope it will help you.
Regards,
Jyothsna D