dimanche 26 juillet 2020

CSS & JS do not work if added dynamically into asp. Net page?

This really is driving me crazy. The story started when I tried to create a drop down list with checked box in an ASP.Net Page

To achieve that, I needed to import:

jquery-3.5.1.slim.min.js
Bootstrap.min.css
Bootstrap-multiselect.css
Popper.min.js
Bootstrap.min.js
Bootstrap-multiselect.js

The dropdownMenu works fine when files are imported by internet.

<head runat="server">
    <title></title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/css/bootstrap-multiselect.css" type="text/css" />
    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/js/bootstrap-multiselect.js"></script>
        <script type="text/javascript">  
            $(function () {
                $('#lstEmployee').multiselect({
                    includeSelectAllOption: true
                });
            });
    </script>  
</head>

But it does not work when I add them to page through ClientSctipt.RegisterStartUpScript in Page_Load event

Appreciate if anyone can give me a hint




Aucun commentaire:

Enregistrer un commentaire