2

I am writing an asp.net website and im trying to use the asp.net button. Though the code behind is correct and i used the update panel, every time i click on the button the code behind does not execute and instead of that the page reloads. Can you please help me?

Here is the part of the code i use the button:

<div class="row">
    <div class="col-lg-8 col-md-offset-4 padding-left-0 padding-top-20">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <asp:UpdatePanel runat="server" ID="UpdatePanel" UpdateMode="Conditional" >

            <ContentTemplate>
                <asp:Button  class="btn btn-primary" ID="btnLogin" runat="server" Text="Log in" OnClick="btnLogin_Click" />
            </ContentTemplate>
                <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnLogin" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
    </div>
</div>
7
  • Does the unwanted behavior happen if you remove the UpdateMode="Conditional" property and the Triggers inner tag of the UpdatePanel? Commented Jul 29, 2014 at 19:33
  • Yeap, still not working. im using the metronic theme, if this matters.. Commented Jul 29, 2014 at 19:48
  • Set a break point (debugger) in the server click event of the button and check whether it is executed. The bootstrap theme should not be a problem. Commented Jul 29, 2014 at 19:52
  • I set two break points, one on the page load event and one on the server click event. both times (when first time loading the page and when the button is clicked) the debugger stops at the page load break point. So server code is never executed but i cant figure out why Commented Jul 29, 2014 at 20:15
  • Try to create the Button Click handler by double clicking on the button in the Visual Studio Designer. If this does not help and you still experience the problem, create a new aspx page with a button and a click handler and test again. Commented Jul 29, 2014 at 20:26

1 Answer 1

1

Finally solved it, somewhere in the master page there was an "action" field in the form, i removed it and its all okay now. Thanks Rumen for the help

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.