You need to sign in to do that
Don't have an account?

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>
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>
Something like this
PageReference pageRef = new PageReference('/apex/YourNewVFPage');
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