Reputation: 51
I have written a C# code to pass TextBox
value of one page to another.
Response.Redirect("SubmittedSuccessfullt.aspx?" + TextBox56.Text.ToString());
TextBox56
has value SJS/187/2000
but when the value is passed to another page and I print it using a Label
it get printed like SJS%2f187%2f2000
.
In the redirected page I have written code in the following way:
Label24.Text = Request.QueryString.ToString();
Please suggest me how can I exactly pass the value of TextBox
to another page and can get the exact value in another page.
Upvotes: 1
Views: 1570
Reputation: 39976
You must encode the value before passing it to next page. like this:
Response.Redirect("second.aspx?Parameter=" + Server.UrlEncode(TextBox1.Text));
Label1.Text = Server.UrlDecode(Request.QueryString["Parameter"].ToString());
Upvotes: 5
Reputation: 2523
try using your code like this :
Label24.Text = Request.QueryString["Parameter"].ToString();
Upvotes: 0
Reputation: 1537
string text = HttpUtility.HtmlEncode(TextBox56.Text);
Response.Redirect("SubmittedSuccessfullt.aspx?" + text);
Your text should now be encoded to not be parsed as html.
Upvotes: 0