Click here to Skip to main content
15,914,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,

I'm using Server.transfer to redirect to some other page in asp.net,

but now the problem is, i want to pass the value from one page to other page,
like we use Request.Querystring["CODE"]

Plzzzz help me to get.,..

thnx
Posted
Comments
Edward Benoit 17-Jun-23 3:54am    
What am I doing incorrectly.
Server.Transfer("~/allProductsOptions.aspx", true);
issn = Request.Form["issn.Trim()"]; // I get null

 
Share this answer
 
Comments
abdul subhan mohammed 22-Apr-14 3:32am    
i'm talking about server.transfer, i knw how in response.redirect
Siva Hyderabad 22-Apr-14 3:42am    
You can't append a query string in Server.Transfer.
You can pass values in Context
Eg:
Context.Items["ParamName"] = value;
check this

C#
protected void Linkbutton1_Click(object sender, EventArgs e)
{
HttpContext CurrContext = HttpContext.Current;
CurrContext.Items.Add("Name", "Shawpnendu Bikash Maloroy");
CurrContext.Items.Add("Address", "Dhaka, Bangladesh");
Sever.Transfer("Destination.aspx");
}


In Destination.aspx Page under Load event write the below code:

C#
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
HttpContext CurrContext = HttpContext.Current;
Response.Write(CurrContext.Items["Name"].ToString()+" ");
Resonse.Write(CurrContext.Items["Address"].ToString());
}
}
 
Share this answer
 
If you are using Server.Transfer to redirect and not disabling PreserveForm property, previous page controls details are available through Page.PreviousPage Property[^]. If you need to specifically pass something through querystring, you can still do that. Just add querystring at the end and you can access that in the redirected page.

You may want to read this MSDN article as well: Cross-Page Posting in ASP.NET Web Pages[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900