【发布时间】:2016-10-24 11:10:37
【问题描述】:
这已经讨论了太多次了,但是这些帖子都没有帮助我。
下面是 .aspx 代码。
<div id="Panel_login" runat="server" class="panel-default">
<asp:UpdatePanel ID="UpdatePanel_login" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:RequiredFieldValidator ID="txtb_loginEmailRequiredFieldValidator" ControlToValidate="txtb_loginEmail" runat="server" ErrorMessage="Email can't be Empty"></asp:RequiredFieldValidator>
<asp:TextBox ID="txtb_loginEmail" CssClass="form-control" placeholder="Your Email" runat="server" TextMode="Email" Width="400px"></asp:TextBox>
<asp:RequiredFieldValidator ID="txtb_loginPasswordRequiredFieldValidator" ControlToValidate="txtb_loginPassword" runat="server" ErrorMessage="Password can't be Empty"></asp:RequiredFieldValidator>
<asp:TextBox ID="txtb_loginPassword" CssClass="form-control" TextMode="Password" placeholder="Password" runat="server" Width="400px"></asp:TextBox>
<asp:Button ID="btn_userlogin" runat="server" OnClick="loginUser" Text="Login" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
下面是我的 .cs 文件代码。
protected void loginUser(object sender, EventArgs e)
{
Response.Redirect("www.google.com");
log.Debug("login_user is called");
}
点击按钮时,它应该触发事件,但它没有发生。
我已尝试为单击此按钮向更新面板添加触发器,但仍然无效。
只有在之前触发同一页面上的另一个按钮时才会触发它。
有人可以建议我在这里缺少什么。
感谢您的帮助。
【问题讨论】:
-
我猜你的
Page_Load错过了!IsPostBack检查。显示它 -
我在 Page_Load() 中什么都没有,应该没关系。它适用于我在页面上的另一个按钮。
-
你怎么知道“它没有发生”?通过不发生重定向,还是通过代码调试?
-
将
ChildrenAsTriggers="true"添加到更新面板 -
也可以参考这个 - stackoverflow.com/questions/25075538/…