引导模态大火而不是ASP按钮的Click事件 [英] Bootstrap Modal fires but not ASP Button Click event

查看:174
本文介绍了引导模态大火而不是ASP按钮的Click事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上就像标题说。

布局:
页w /一个DataGrid和按钮的动态量。

Layout: Page w/ a DataGrid and a dynamic amount of buttons.

拟功能:
当点击一个按钮,模式将显示,那么ASP按钮单击事件将触发。

Intended functionality: When one of the buttons is clicked, the modal will show, then the asp button click event will fire.

功能的现在:
ASP按钮后,模态显示,事件将不会触发。

Functionality as of right now: ASP Button is clicked, Modal shows, Event will not fire.

任何人都知道它可能得到两个火?

Anyone know if its possible to get both to fire?

下面是我的模式:

 div id="example" class="modal hide fade in" style="display: none;">
              <div class="modal-header">
                  <a class="close" data-dismiss="modal">x</a>
                  <h3>Enter Comments Below:</h3>
              </div>
              <div class="modal-body">
                  <h4>Comments</h4>                  
              </div>
              <div class="modal-footer">
                  <a href="#" class="btn btn-success">Call to action</a>  
                    <a href="#" class="btn" data-dismiss="modal">Close</a>                   
              </div>
          </div>

下面是按钮:

<asp:Button ID="TestButton2" runat="server" Text="Comments"
OnClick="TestButton_Click"/>

下面的按钮从code背后点击事件。

Here is the buttons click event from the code Behind.

protected void TestButton_Click(object sender, EventArgs e)
                        {

                         // This does something

                        }

下面是显示按钮被点击时,模态Jquery的:

Here is the Jquery that shows the modal when the button is clicked:

 <script type="text/javascript">
           $('input[name$="TestButton2"]').on("click", function () {

               $('#example').modal('toggle');
               return false;

           });
     </script>

任何人有什么想法?我想过一个隐藏字段,但不知道是否这将真正发挥作用。这可能只是无法用WebForms的,但想到我会问。
在此先感谢您的帮助。

Anyone have any ideas? I've thought about a hidden field but don't know if that would really work. It may just not be possible with WebForms but thought I would ask. Thanks in advance for your help.

推荐答案

在您按一下按钮使用ClientScriptManager调用Java脚本

call java script using ClientScriptManager on your button click

protected void TestButton_Click(object sender, EventArgs e)
                    {

                     // do something then call modal
ClientScript.RegisterStartupScript(GetType(), "Show", "<script> $('#example').modal('toggle');</script>");
                    }

这篇关于引导模态大火而不是ASP按钮的Click事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆