简体   繁体   中英

Launch Modal on Page_Load with JavaScript doesn't work - ASP.NET

I want to launch a modal on the Load_Page on my ASP.NET C# application and doesn't work. This is the JavaScript code to launch it:

        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "none", "<script>$('#miModal').modal('show');</script>", false);

The thing is, I use the same modal with the same code in one button, and it works fine. What could be the problem? There is something working different with the Page_Load event??

I used UpdatePanel, ContentTemplate in the button and ScriptManager in the .aspx file. Maybe this matters.

First, make sure your jquery library already loaded. Also, there is a change the control was not load to the DOM yet, so use:

<script>$( document ).ready(function() {$('#miModal').modal('show');});</script>

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