我有一个非常简单的文本框和按钮,但按钮点击事件不是第一次触发(仅在第二次点击时触发)
<asp:TextBox ID="TxtSurvey" runat="server"></asp:TextBox> <br />
<asp:Button ID="BtnGoSurvey" runat="server" Text="LetsGo"/>
代码也非常简单
Protected Sub BtnGoSurvey_Click(sender As Object, e As EventArgs) Handles BtnGoSurvey.Click
Session("IDSurvey") = TxtSurvey.Text
BtnGoSurvey.PostBackUrl = "~/Survey.aspx"
End Sub
我做错了什么? 谢谢你的帮助
答案 0 :(得分:1)
如果您可以使用Response.Redirect,那么以下应该可以工作:
Protected Sub BtnGoSurvey_Click(sender As Object, e As EventArgs) Handles BtnGoSurvey.Click
Session("IDSurvey") = TxtSurvey.Text
Response.Redirect("~/Survey.aspx",True)
End Sub