简体   繁体   中英

Asp.net button onclick event is not firing serverside code

This has been discussed too many times already, but none of those threads helped me.

Below is .aspx code.

<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>

Below is my .cs file code.

 protected void loginUser(object sender, EventArgs e)
 {
     Response.Redirect("www.google.com");
     log.Debug("login_user is called");    
 }

On click of button, it should fire event, but it is not happening.

I have tried adding triggers to Update Panel for this button click, still didnt work.

It only gets fired when another button on same page is fired previously.

Can someone suggests what I am missing here.

Thanks for help.

I have seen the event never getting wired up. Try...

(1) In design mode delete the button, drag a new one back on the design surface, then rename your button. OR

(2) Go into design view, click the button, then properties, look at the Lightening Bolt Icon (event) remove that event, save, and add it back and save.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM