0

I have a basic .net website with bootstrap (basically simply started a new project with vs-2015, web-form).

For some unknown reason the navbar collapsing feature does not work properly when I set the Bootstrap 3 resize tool to col-md (see bellow): enter image description here

Every other sizing works properly. The problem only occurs with col-md when I have a lot of <li>

Here is my master page code (HTML)

<!DOCTYPE html>

<html lang="en">
<head runat="server">
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title><%: Page.Title %> - My ASP.NET Application</title>

    <asp:PlaceHolder runat="server">
        <%: Scripts.Render("~/bundles/modernizr") %>
    </asp:PlaceHolder>
    <webopt:bundlereference runat="server" path="~/Content/css" />
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />

</head>
<body>
    <form runat="server">
        <asp:ScriptManager runat="server">
            <Scripts>
                <%--To learn more about bundling scripts in ScriptManager see http://go.microsoft.com/fwlink/?LinkID=301884 --%>
                <%--Framework Scripts--%>
                <asp:ScriptReference Name="MsAjaxBundle" />
                <asp:ScriptReference Name="jquery" />
                <asp:ScriptReference Name="bootstrap" />
                <asp:ScriptReference Name="respond" />
                <asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
                <asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
                <asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
                <asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
                <asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
                <asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
                <asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
                <asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
                <asp:ScriptReference Name="WebFormsBundle" />
                <%--Site Scripts--%>
            </Scripts>
        </asp:ScriptManager>

        <div class="navbar navbar-inverse navbar-fixed-top">
            <div class="container">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" runat="server" href="~/">Application name</a>
                </div>
                <div class="navbar-collapse collapse">
                    <ul class="nav navbar-nav">
                        <li><a runat="server" href="~/">Home</a></li>
                        <li><a runat="server" href="~/About">About</a></li>
                        <li><a runat="server" href="~/Contact">Contact</a></li>
                        <li><a runat="server" href="~/About">About</a></li>
                        <li><a runat="server" href="~/Contact">Contact</a></li>
                        <li><a runat="server" href="~/About">About</a></li>
                        <li><a runat="server" href="~/Contact">Contact</a></li>
                        <li><a runat="server" href="~/Contact">Contact</a></li>
                        <li><a runat="server" href="~/About">About</a></li>
                        <li><a runat="server" href="~/Contact">Contact</a></li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="container body-content">
            <asp:ContentPlaceHolder ID="MainContent" runat="server">
            </asp:ContentPlaceHolder>
            <hr />
            <footer>
                <p>&copy; <%: DateTime.Now.Year %> - My ASP.NET Application</p>
            </footer>
        </div>
    </form>
</body>
</html>

Does anyone have a idea on how to fix this issue?

Hans Vallee
  • 79
  • 1
  • 10
  • 1
    Nowhere in the HTML code you gave do you have a `col-md`. – Caleb Anthony Aug 02 '16 at 19:08
  • Just to be clear, resizing my browser window has the same effect than using the google Boostrap tool... – Hans Vallee Aug 02 '16 at 19:09
  • @caleb, the col-md is just the sizing option in the google bootstrap tool where the problem happens. There are NO col-* whatso ever in the code. – Hans Vallee Aug 02 '16 at 19:10
  • If you're referring to the `navbar toggle button` not functioning when pressed/clicked you should check your console for errors first. – vanburen Aug 02 '16 at 19:12
  • @vanburen, negative. I am NOT refering to any issues with the toggle button... that works fine... The problem is that the nav bar is not collapsing when resizing when on a col-md size view port (using the google bootstrap tool or sizing window manually) – Hans Vallee Aug 02 '16 at 19:15
  • @all, there are no console error. – Hans Vallee Aug 02 '16 at 19:16
  • 1
    It's not clear what you are asking because the your example does collapse but if you mean the links overflowing to a new line prior to collapsing (as in the image you posted) its because you have so many links, thats all. And it collapses by default @ 767px, not 991px (MD). – vanburen Aug 02 '16 at 19:18
  • @vanburren, yes I am referring to the fact that the collapse does not happen when it should. Basically, it collapses properly for sm and xs view-port but not for md. – Hans Vallee Aug 02 '16 at 19:21
  • @vanburren, thanks for this: "And it collapses by default @ 767px, not 991px (MD)" I was under the impression that it would collapse when the content overflows... – Hans Vallee Aug 02 '16 at 19:22
  • @everyone, anyone knows if there is a way to FORCE COLLAPSE at 991px (md)? – Hans Vallee Aug 02 '16 at 19:24
  • If you need the collapse to happen at a different width you have to change this yourself. See [navbar-default](https://getbootstrap.com/components/#navbar-default) and https://stackoverflow.com/questions/18192082/bootstrap-3-navbar-collapse. – vanburen Aug 02 '16 at 19:25
  • @vanburen, this looks exacly like what I need THANKS! I will have a look and try it out but I do have a good feeling about this... Please add as "Answer" so I can vote for you when I am done trying it... – Hans Vallee Aug 02 '16 at 19:29

1 Answers1

0

The explanations from @vanburen where correct. The bootstrap collapse DOES NOT trig based on available (full width - used with) display width as I was believing originally. It triggers on width "sm" so the only way to fix my problem is by overriding the bootstrap.

Thanks again @vanburen, I wish you had put it in answers so I could have voted for you...

Hans Vallee
  • 79
  • 1
  • 10