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);
}
1 comment:
Adea mein job kaise mil gaya; jab Server.Transfer hi nahi pata :(
Post a Comment