简体   繁体   English

在asp.net中显示带有按钮单击的BootBox

[英]Showing BootBox with button click in asp.net

Hi I am a beginner and learning asp.net by myself. 嗨,我是初学者,自己学习asp.net。 I want to show a confirmation dialog using bootbox. 我想使用Bootbox显示一个确认对话框。 I searched a lot but couldn't find the solution for this. 我进行了很多搜索,但找不到解决方案。 The bootbox documentation is also not precise really. 引导箱文档确实也不精确。

Here is the asp.net code for modal dialog: 这是模式对话框的asp.net代码:

 <!--BootBox Dialog --> <div id="myModal" class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-body"> <button type="button" class="close" data-dismiss="modal">&times;</button> Are you Sure from master page? </div> <div class="modal-footer"><asp:Button runat="server" CssClass="btn btn-primary" ID="okButton" Text="OK"/></div> </div> </div> </div> 

And by button: 并通过按钮:

  <asp:LinkButton runat="server" ID="EditButton" CssClass="btn btn-primary" ClientIDMode="Static"> <i class="fa fa-edit"></i>&nbsp;Edit Selected </asp:LinkButton> 

The bootbox JavaScript to show confirm dialog: 引导JavaScript显示确认对话框:

 <script> $("#myModal").on("show", function() { // wire up the OK button to dismiss the modal when shown $("#myModal a.btn").on("click", function(e) { console.log("button pressed"); // just as an example... $("#myModal").modal('hide'); // dismiss the dialog }); }); $("#myModal").on("hide", function() { // remove the event listeners when the dialog is dismissed $("#myModal a.btn").off("click"); }); $("#myModal").on("hidden", function() { // remove the actual elements from the DOM when fully hidden $("#myModal").remove(); }); $("#myModal").modal({ // wire up the actual modal functionality and show the dialog "backdrop" : "static", "keyboard" : true, "show" : true // ensure the modal is shown immediately }); </script> 

Where should I pass the ID of the button and show the modal? 我应该在哪里传递按钮的ID并显示模式? Please help. 请帮忙。

Used this-- 用这个-

$("#EditButton").on("click", function(){

//Do your Stuff here } //在这里做你的东西}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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