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
zubair shareef mohammadzubair shareef mohammad 

Doubt in pagereference

Hi this is Zuber
I am written a code on navigating a page, but I cant execute 
Please help me anyone
------------------------------------------
VF Page Code:
-------------
<apex:page sidebar="false" setup="false" showHeader="true" tabStyle="Customer__c" controller="SourcePageController" >
<apex:sectionHeader title="Source Page" subtitle="Page Navigation"/>
<apex:form >
    <apex:pageblock title="Source Page Block">
        <apex:pageblockSection title="Source Page Section" collapsible="false" columns="1">
            <apex:inputtext label="Enter Customer Id : " value="{!customerId}"/>
            <apex:inputtext label="Enter Customer Name: " value="{!customerName}"/>
            <apex:commandButton value="Goto Target Page" action="{!GotoTargetPage}"/>
        </apex:pageblockSection>
    </apex:pageblock>
</apex:form>
</apex:page>
--------------------------------------------------------------------------------------

Controller Class:
-----------------
public class SourcePageController 
{
    Public string customerId{get;set;}
    Public string customerName {get;set;}
    Public PageReference GotoTargetPage()
    {
        //Pagereference pgRef = new PageReference('/apex/TargetPage?custId='+customerId +'&custName='+customerName);
      PageReference pgRef = Page.TargetPage;
        pgRef.getParameters().Put('custID',customerId);
        pgRef.getParameters().Put('custName',CustomerNAme);
        pgRef.SetRedirect(true);
        return pgRef;
    }
}
 
Best Answer chosen by zubair shareef mohammad
karthikeyan perumalkarthikeyan perumal
Hello, 

I checked your code.. its working without having any issue. its redirected to spacified page(.TargetPage) with QueryString of CustomerID and Name). please refer image below. if you need something else let me know. 

User-added image
User-added image

Hope this will clear. 

Thanks
karthik
 

All Answers

karthikeyan perumalkarthikeyan perumal
Hello, 

I checked your code.. its working without having any issue. its redirected to spacified page(.TargetPage) with QueryString of CustomerID and Name). please refer image below. if you need something else let me know. 

User-added image
User-added image

Hope this will clear. 

Thanks
karthik
 
This was selected as the best answer
sandeep madhavsandeep madhav
Hi,

Hope this helps,

Controller:
public class SourcePageController {
    Public string customerId{get;set;}
    Public string customerName {get;set;}
    Public PageReference GotoTargetPage() {
        Pagereference pgRef = new PageReference('/apex/TargetPage?custId='+customerId +'&custName='+customerName);
        pgRef.getParameters().Put('custID',customerId);
        pgRef.getParameters().Put('custName',CustomerNAme);
        pgRef.SetRedirect(true);
        return pgRef;
    }
}

Mark this answer as best if this helps.