Unable to raise div with ClientScript.RegisterStartupScript

846 views Asked by At

Actually, I'm trying to show a div on a condition by using ClientScript.RegisterStartupScript.

But, I'm unable to show that. My code goes like this :

ClientScript.RegisterStartupScript(this.GetType(), "show", "<script> $('#PopupMessgebox').modal('toggle');</script>");

PopupMessgebox is the div id

Actually, its a Login form and the login click is designed using list li and for the first time, on clicking that the popup (div) is showing and it is working fine. But, if there is any authentication problem, we are trying to show an error in the div and that div should be popped out. But that doesn't work :(

My div code :

 <div id="PopupMessgebox" class="deleteModal modal hide">
                <div class="modal-body">
                    <div style="overflow: hidden;">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>
                    </div>
                    <div class="alert-delete">
                        <dx:ASPxLabel ID="lbl_Msg" runat="server" Text="Hi" Font-Bold="True" Font-Size="Small"></dx:ASPxLabel>
                    </div>
                </div>
                <div class="modal-footer">
                    <div style="text-align: center;">
                        <button class="button grey-button" data-dismiss="modal" aria-hidden="true">Cancel</button>
                    </div>
                </div>
            </div>
2

There are 2 answers

3
bigcakes On

Try wrapping the javascript in the document on ready

ClientScript.RegisterStartupScript(this.GetType(), "show", "<script> $(document).ready(function() {$('#PopupMessgebox').modal('toggle');}</script>");
3
Bibhu On

Try this :

ClientScript.RegisterStartupScript(this.GetType(), "show", "<script type='text/javascript'> $('#PopupMessgebox').modal('toggle');</script>");