简体   繁体   中英

How to prevent modal popup asp.net

I am using javascript modal in my asp.net project. I am calling it from dinamicly created asp.net buttons in code behind with this code ;

Code Behind

ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "$(function() { mesInfo(); });", true);

And HTML

 <script>   

    function mesInfo() {
        $('#message-box-info').modal('show');
    }    


</script>

Page working normally and calls modal when user click those dinamicly created asp.net buttons. Problem is when user refresh page or use browser back button after calling modal once, modal pops again anyway. How can I prevent this. Thank You

Instead of invoking the modal using ScriptManager.RegisterStartupScript in code behind.

you can add the event listener using Jquery

say
is your button, your jquery event would be like

$('.button').live('click',function(){
  $('#message-box-info').modal('show');
});

here '.button' is the class i have considered for the button. Hope this will help

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