function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
azhar khasimazhar khasim 

Unable to redirect from Visualforce page to other website contact us page using Command Button.

Hello Everyone,

I had an issue with Commandbutton which I need to redirect the page from the Visualforce page to some other company Website Contact Us page.

Here is my CommandButton code and Controller class code.

VF Page CommandButton:

 <apex:commandButton style="color:white; background-color:red; background-image:none; width:150px; height:35px" action="{!Cancel}" value="Cancel"  />

Controller Class:

 public PageReference Cancel(){
        PageReference pr = new PageReference('/www.bren.com/residential/contact');
        pr.setRedirect(true);
        return pr;
    }


Please help me with this issue.

Thanks and Regards,
Azar Khasim.
Best Answer chosen by azhar khasim
Maharajan CMaharajan C
Hi Azar,

Try the below change in method it will work:

Public pagereference Cancel()
{
        PageReference pr = new PageReference('https://www.bren.com/residential/contact');
        pr.setRedirect(true);
        return pr;
}


Thanks,
Maharajan.C

All Answers

Maharajan CMaharajan C
Hi Azar,

Try the below change in method it will work:

Public pagereference Cancel()
{
        PageReference pr = new PageReference('https://www.bren.com/residential/contact');
        pr.setRedirect(true);
        return pr;
}


Thanks,
Maharajan.C
This was selected as the best answer
azhar khasimazhar khasim
Hello Maharajan,

Thank you it's working,
Actually, I have tried the same way yesterday, but it didn't work at that time.

Anyway thanks for your help Mr. Maharajan.

Thanks and regards,
Azar Khasim.