Roberto Lopez
Roberto Lopez

Reputation: 55

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.

Upvotes: 0

Views: 340

Answers (1)

Itai
Itai

Reputation: 56

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>

Upvotes: 1

Related Questions