CODEDIGEST
Home Articles CodeDigest Tutorials FAQs
Home > CodeDigest >  
Technologies
 


Pass Value to Destination Page When Using Server.Transfer in Asp.Net
Submitted By Satheesh Babu B
On 8/25/2009 7:58:27 AM
Tags: ASP.Net,CodeDigest  

Pass Value to Destination Page When Using Server.Transfer in Asp.Net

 

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);

    }

 

Recent Codes
  • View All Codes..