0
我有一個輸入文本框和按鈕,當按下按鈕時,文本框中的任何內容都應作爲查詢字符串追加並重定向到另一個url。但是,在重定向發生之前,我需要點擊兩次按鈕。Response.Redirect需要點擊兩次
這是ASPX代碼
<div class="userInputTextBox" style="margin-left: auto; margin-right: auto; margin-top: 10px;">
<asp:TextBox
placeholder="Enter costumer ID"
ID="TextBoxID1"
runat="server"
AutoPostBack="true"
Columns="80"
Visible="true">
</asp:TextBox>
<asp:Button runat="server" Text="Search" OnClick="Search" />
</div>
代碼搜索方法落後。
protected void Search(object sender, EventArgs e)
{
Response.Redirect(String.Format("UserDetail.aspx?UserID={0}", Server.HtmlEncode(TextBoxID1.Text)));
}
我編輯了自己的冠軍。請參閱:「[應該在其標題中包含」標籤「](http://meta.stackexchange.com/questions/19190/)」,其中的共識是「不,他們不應該」。 –
注意該URL應該有'Server.URLEncode',而不是'HtmlEncode'。 – SilverlightFox