Bootstrap dropdown menu does not work on Asp.net website

Asked

Viewed 4,213 times

2

I have a page index.html that the dropdown menu feature works normally, but when I migrated to stopped working.

I’m using a page Default.aspx who inherits from the masterpage.master.

<div class="btn-group pull-right">
    <a href="Default.aspx" class="btn btn-primary">Home</a>
    <div class="btn-group">
        <a href="QuemSomos.aspx" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">Quem Somos</a>
        <button class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
            <span class="caret"></span>   
        </button>

        <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu">
            <li><a href="#">Certificações</a></li>
            <li><a href="#">Alianças Estratégicas</a></li>
        </ul>
    </div>
</div>

3 answers

2


Talk, man.

  1. Make sure that the jQuery is being loaded;
  2. Make sure that the bootstrap.js is being loaded;
  3. Make sure that no javascript error occurs that prevents the dropdown from being enabled;

Assuming the problem is not one of the above:

  1. Try to activate the toggle dropdown manually in the event document.ready.
    <script type="text/javascript">
        $(document).ready(function(){
            $('.dropdown-toggle').dropdown();
        })
    </script>
  • Thanks for trying to help, Alan. I have another feature on the same page that works, but this feature doesn’t work. I would like to try the third option, but I don’t know how to do it. Thanks.

  • How do I test the 3rd option? Thanks.

  • 1

    Hello, Fabricio. You probably have some jquery code enabled in the event Document.ready. If not, put the snippet below before closing the body tag (</body>): <script> $(Document). ready(Function(){ $('.dropdown-toggle').dropdown(); }); </script>

  • 1

    It worked Alan. Thank you very much. God bless you.

1

From what I’ve seen the code works normally.

http://jsfiddle.net/moykn/Lz82E/

Make sure that, in addition to what has already been quoted by Alan R., Jquery is also being loaded even before Bootstrap itself.

  • 1

    Moykn. This link is very useful for testing. Thanks.

0

Hello! I had the same problem in my layout,when using the Google chromer inspector to check if there were any errors in my code, I was informed of the version I was using of jquery was not compatible, which I should use from the version of jquery 1.9.1 onwards,I changed and my problem was solved, I hope to help.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.