简体   繁体   English

如何将文本框的准确值从一页传递到另一页

[英]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. 我已经编写了C#代码,以将一页的TextBox值传递给另一页。

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 . TextBox56值为SJS/187/2000 TextBox56但是当该值传递到另一页并使用Label打印时,它的打印方式类似于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. 请建议我如何将TextBox的值准确传递到另一个页面,并在另一个页面中获取确切的值。

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());

尝试像这样使用您的代码:

Label24.Text = Request.QueryString["Parameter"].ToString();
string text = HttpUtility.HtmlEncode(TextBox56.Text);
Response.Redirect("SubmittedSuccessfullt.aspx?" + text);

Your text should now be encoded to not be parsed as html. 现在,您的文本应该被编码为不被解析为html。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM