+ Start a Discussion

Onclick of command button

Hai everyone,






I have a command button used in one visualforce page.Can I navigate to another visualforce page onclicking that command button.Please help...........






    public Pagereference cancel()
        PageReference prCancel = new PageReference('/apex/visualforcePageName');
        return prCancel;



hope this will help you

Shailesh DeshpandeShailesh Deshpande

you need to use the action attribute of command button which calls a function in your controller....


something like this :


<apex:commandbutton action = "{!go_to_other_ page}"  value = "take me other page"/>


and in your controller define a function called go_to_other_ page()


public Pagerefernce go_to_other_ page()


     // place the code that sunil has given