How to open another Visualforce page from current Visualforce page in Salesforce?

How to open another Visualforce page from current Visualforce page in Salesforce?

Sample Code:


Visualforce page:

<apex:page controller=”sample”>
            <apex:commandButton value=”Open” action=”{!openPage}”/>   
</apex:page>

Apex Class: 

public class sample
{
    public pageReference openPage()
    {
        pageReference pg = new pageReference(‘/apex/Name_Of_The_Page’);
        pg.setRedirect(true);
        return pg;
    }      
}

Leave a Reply