When cancel button is clicked in visualforce page, it has to redirect to home page.Instead I'm getting the same visualforce page.Kindly help.
public PageReference cancel()
{
return null;
}
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityMethod -
Using html-5 in doctype in visualforce page means you should use html-formnovalidate and immediate in cancel button. For example
<apex:commandButton action="{!cancel}" value="Cancel" immediate="true"
html-formnovalidate="formnovalidate" />
I can see you have returned "null" from "page reference method" used for cancel. When you return null salesforce keeps redirects to same page. That is the reason when you are using this method, salesforce is keeping you at same page.