Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi guys,

Can I know how can I pass a query string between two *.cs pages? I have a textbox in one page. I want its text to be passed to other page and view as a text of label.

Thanks.
Posted
Updated 7-Sep-11 19:53pm
v2
Comments
Prerak Patel 8-Sep-11 0:11am    
Don't repost your question.
Prerak Patel 8-Sep-11 0:12am    
And use proper case in question.

In first page, you can write this on button click
C#
Response.Redirect("yourpage.aspx?qs=" + Server.UrlEncode(textbox1.text));


On the other page, you can get the value on page load,
C#
string QueryStringValue = Server.UrlDecode(Request.QueryString["qs"].ToString());
 
Share this answer
 
Comments
Member 8214635 8-Sep-11 0:22am    
its not working? have any other idea?
Jephunneh Malazarte 8-Sep-11 0:37am    
if it's not working. would you mind telling us the error? :)
or how did you implement that code snippet?

Thanks.. i am curious why is it not working, though it's working perfectly fine in my local :)
Response.Redirect("Page2.apsx=?ValueToPass="+textBox1.tex1.trim());

in page2 load

string val=request.querystring["ValueToPass"].tostring();
 
Share this answer
 
Comments
Member 8214635 8-Sep-11 0:27am    
on second page i got this error: "Object reference not set to an instance of an object."
Member 8214635 8-Sep-11 0:37am    
from first page i pass :
Response.Redirect("RadioBtn.aspx?GI=" + txtHideImage.Text.Trim());
from second page i pass:
string PassValue;
PassValue = Request.QueryString["GI"];

when i use tostring with request.querystrin["gi']. it gives a error "Object reference not set to an instance of an object."

what can i do in this. pls help me..
[no name] 8-Sep-11 0:39am    
is the 2 pages in the same level or folder & be sure u use the same name in querystring in 2 pages
[no name] 8-Sep-11 0:41am    
what value in txtHideImage.Text
is it normal string or what??
if it's not string just remove .tostring() from page2 & check it again
Member 8214635 8-Sep-11 0:44am    
its normal string value. i remove tostring from it. but recent value is not coming in the second page.

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