Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法将输入从文本框传递到查询字符串,然后将该字符串保留在此框中_C#_Asp.net - Fatal编程技术网

C# 无法将输入从文本框传递到查询字符串,然后将该字符串保留在此框中

C# 无法将输入从文本框传递到查询字符串,然后将该字符串保留在此框中,c#,asp.net,C#,Asp.net,我有一个简单的ASP.net页面: <form id="form1" runat="server"> <p><asp:TextBox id="input_box" runat="server"></asp:TextBox> <asp:Button Text="OK" runat="server" OnClick="run" /></p> </form> 问题是,当查询字符串不为空时,无

我有一个简单的ASP.net页面:

<form id="form1" runat="server">
    <p><asp:TextBox id="input_box" runat="server"></asp:TextBox>

       <asp:Button Text="OK" runat="server" OnClick="run" /></p>
 </form>

问题是,当查询字符串不为空时,无法将输入框中的字符串传递给查询字符串。如何纠正它?

如果我理解正确的话

我认为回发邮件可能是在发送到查询字符串之前清除了您的文本框。 尝试将其添加到页面加载中 如果(iPostBack) 返回

这将停止清除inputbox或将其重置回原始查询字符串

如果(!IsPostBack){//pageLoad event}是我的问题的解决方案,希望这有帮助。谢谢你的暗示!
protected void Page_Load(object sender, EventArgs e)
{       
    input_box.Text = Request.QueryString["input"];
}
protected void run(object sender, EventArgs e)
{
    string url = string.Format("?input={0}", input_box.Text);
    Response.Redirect(Request.Url.AbsolutePath + url);
}