ASP.NET button inside bootstrap modal not triggering click event

后端 未结 2 329
生来不讨喜
生来不讨喜 2020-12-30 06:14

I\'m working in Bootstrap modal in my asp.net site, modal is working fine but the button btnSaveImage inside modal footer is not firing click event, I also have a masterpage

相关标签:
2条回答
  • 2020-12-30 07:07

    You can use the ASP Button like in your example

    <div class="modal-footer">
       <button data-dismiss="modal" class="btn  btn-large"> Close</button>
       <asp:Button runat="server" ID="btnSaveImage" Text="Save Image" CssClass="Greengradiant btn- large" OnClick="btnSaveImage_Click" />
    </div>
    

    just try the UseSubmitBehavior="false" like said skhurams and combine it with the data-dismiss="modal"

    <div class="modal-footer">
       <button data-dismiss="modal" class="btn  btn-large"> Close</button>
       <asp:Button runat="server" ID="btnSaveImage" Text="Save Image" CssClass="Greengradiant btn- large" OnClick="btnSaveImage_Click" UseSubmitBehavior="false" data-dismiss="modal" />
    </div>
    

    this will close the modal and trigger the postback

    0 讨论(0)
  • 2020-12-30 07:17

    I'd like to add another point here. I faced this issue because my final rendered modal dialogs were placed outside the WebForms <form> tag, and using the UseSumbitBehavior="false" did not solve my problem. Moving the modal dialog divs inside the form solved the issue.

    $("div.modalForm").appendTo($("form:first"));
    
    0 讨论(0)
提交回复
热议问题