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
Suneel B 9Suneel B 9 

custom button on vf page which navigates to another vf page

Hwy guys,  I created a visual force page for Opportunities which contains a custom button and when we press that button it should navigate to another visual force page.
Can anyone help me.

this is the initial VF page:

<apex:page standardController="Opportunity">
<apex:sectionHeader title="Edit Opportunity" subtitle="{!opportunity.name}"/>

<apex:form >
<apex:pageBlock title="Opportunity Edit" helpTitle="Opportunity" helpUrl="Opportunity">
<apex:pageBlockButtons >
<apex:commandButton value="Next" onclick="OpenPage('google'); return false;"/>
When we press the next button it should navigate to another visual force page



</apex:pageBlockButtons>
<apex:pageBlockSection title="Opportunity Information" collapsible="false" >

<apex:outputText value="{!Opportunity.Owner}" 
label="Opportunity Owner"/>

<apex:inputField value="{!Opportunity.Amount}"
label="Amount"/>

<apex:inputCheckbox value="{!Opportunity.IsPrivate}"
label="Private"/>

<apex:inputField value="{!Opportunity.CloseDate}" required="true"
label="CloseDate"/>

<apex:inputField value="{!Opportunity.Name}" required="true"
label="Opportunity Name"/>

<apex:inputText value="{!Opportunity.NextStep}"
label="NextStep"/>
<apex:inputText value="{!Opportunity.Account}" 
label="Account Name"/>

<apex:inputfield value="{!Opportunity.StageName}" 
                 required="true" 
                 id="stage" 
                 onclick="changeblock();"/>
<apex:inputField value="{!Opportunity.Type}"
label="Type"/> 
<apex:inputField value="{!Opportunity.LeadSource}"
label="LeadSource"/> 

<apex:inputText value="{!Opportunity.Campaign}"
label="Primary Campaign Source"/>

<apex:inputText value="{!Opportunity.Rating__c}"
label="Rating"/>
</apex:pageBlockSection>
</apex:pageBlock>

</apex:form>
</Apex:page>
 
ThousifAli99ThousifAli99
Have you tried using the Apex PageRefrence.. 
Something like this

PageReference pageRef = new PageReference('/apex/YourNewVFPage');
 
Amit Chaudhary 8Amit Chaudhary 8

Please try below. I hope that will help u

public PageReference Search()
    {
        return new PageReference('/apex/YourNewVFPage');

    }

Please let us know if this will help you

Thanks
Amit Chaudhary