I have an ASP.NET site and I have a page which uses a url query string:
routeToScene.aspx?RunNumber=3253665
This loads fine when I pass the parameter RunNumber=XXXXXXX
in the URL.
What I want to do is load this page by passing the RunNumber=XXXXXXX
via a text box on another page called: routToHospitalParam.aspx
with a simple submit button that takes the value in the textbox and passes it to the URL of the second page. This should be simple and I feel foolish for not finding an answer.
This is the code in the routeToHospitalParam.aspx
page...
<asp:TextBox ID="TextBox1" Width="80px" MaxLength="7" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Submit" PostBackUrl="~/MAP/routeToHospital.aspx" + TextBox1.text />
The issue is when I try use the TextBox1.value
(assuming that is correct) in the PostBackUrl
which loads the other page.
You can do this
In aspx change code to handle onclick event:
<asp:Button ID="Button1" runat="server" Text="Submit"
OnClick="Button1_OnClick" />
In codebehind button click event redirect user with queryprameter:
protected void Button1_OnClick(object sender, EvenArgs e)
{
Response.redirect("~/MAP/routeToHospital.aspx?RunNumber=" + HttpUtility.UrlEncode(TextBox1.text));
}