Cannot pass a input from text box to a query string and then keep the string in this box.
Posted
by Nikita Barsukov
on Stack Overflow
See other posts from Stack Overflow
or by Nikita Barsukov
Published on 2010-05-28T09:12:08Z
Indexed on
2010/05/28
10:11 UTC
Read the original article
Hit count: 204
I have a simple ASP.net page:
<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>
I want to send input from input_box to a query string, and then keep this input in the input_box when the page reloads.
That's the code behind page:
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);
}
Problem is that when query string is not empty, string from input_box cannot be passed to query string. How to correct it?
© Stack Overflow or respective owner