Abhishek Pradhan
Abhishek Pradhan

Reputation: 51

How to pass exact value of textbox from one page to another

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

Answers (3)

Salah Akbari
Salah Akbari

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

CodeMonkey
CodeMonkey

Reputation: 2523

try using your code like this :

Label24.Text = Request.QueryString["Parameter"].ToString();

Upvotes: 0

Erik Karlstrand
Erik Karlstrand

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

Related Questions