CSS and JS of Bootstrap Toggle are not working after UpdatePanel was triggered in Asp.Net

Viewed 97
1 Answers

Try this - the secret is to create a function that you want to run each time a page is loaded - and use add_pageLoaded to make sure it's called after an async postback too.

<script type="text/javascript">
    $(document).ready(function(){        
        docReadyHandler();
        Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(
           docReadyHandler
        );
    });
    
    function docReadyHandler(){
        // code you want to run when the document is ready
    }
</script>

You can also set it in codebehind

ScriptManager.RegisterStartupScript(Me.UpdatePanel, GetType(string), "startupScript", "docReadyHandler();", true)
Related