CODEDIGEST InstallShield
Home Articles CodeDigest Tutorials InstallShield FAQs
Skip Navigation LinksHome » CodeDigest » Pass Value to Destination Page When Using Server.Transfer   You are not logged in.
Search
 

Sponsors
InstallShield
 

Sponsored Links
 

Technologies
 

CodeDigest Navigation
 

Technology News
No News Feeds available at this time.
 

Community News
No News Feeds available at this time.
 
Pass Value to Destination Page When Using Server.Transfer
Pass Value to Destination Page When Using Server.Transfer
Submitted By Satheesh Babu
On 8/25/2009 7:58:27 AM
Tags: ASP.Net,CodeDigest  

Pass Value to Destination Page When Using Server.Transfer

It will not be possible to pass value as query string to the destination page when using Server.Transfer.

To pass value from source page to destination page when using Server.Transfer we can use the Item collection in HttpContext object. The below code does that,

Source Page
protected void Button1_Click(object sender, EventArgs e)

    {

         HttpContext CurrentCon = HttpContext.Current;

         CurrentCon.Items.Add("CatID", "Computer");

         Server.Transfer("Destination.aspx");

    }


Destination Page

protected void Page_Load(object sender, EventArgs e)

    {

        HttpContext CurrentCon = HttpContext.Current;

        string CatID = CurrentCon.Items["CatID"].ToString();

 

        Response.Write(CatID);

    }

 

Do you have a working code that can be used by anyone? Submit it here. It may help someone in the community!!