代码之家  ›  专栏  ›  技术社区  ›  MX313

引导菜单下拉列表不工作ASP。净额

  •  0
  • MX313  · 技术社区  · 7 年前

    菜单下拉不是下拉,单击时不会发生任何事情。我已经搜索了所有的帖子,仍然无法让它工作。我的asp中有一个下拉列表,如下所示。net webforms项目。

    <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle" href="#" id="myAccount" data-toggle="dropdown">My Account<span class="caret"></span></a>
          <div class="dropdown-menu" aria-labelledby="bd-versions">
            <a class="dropdown-item" href="/docs/4.1/">Messages</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item" href="/docs/4.1/">Subscription</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item active" href="/docs/4.0/">Profile</a>
          </div>
    </li>
    

    <asp:ScriptManager runat="server">
                <Scripts>
                    <%--To learn more about bundling scripts in ScriptManager see https://go.microsoft.com/fwlink/?LinkID=301884 --%>
                    <%--Framework Scripts--%>
                    <asp:ScriptReference Name="MsAjaxBundle" />
                    <asp:ScriptReference Name="jquery" />
                    <asp:ScriptReference Name="bootstrap" />
                    <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>
    

    我错过了什么?另一个可能的线索是,当我缩小窗口大小,响应引导菜单崩溃时,“汉堡”在扩展时只闪烁一秒钟,然后自行崩溃。

    使现代化 :我根据建议添加了以下CDN参考,并且效果良好。对于如何在VS17中为jquery引导和popper绑定这些脚本,我感到困惑。

        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
    

    这是我在bundleconfig中的脚本引用。cs,现在他们是如何在网站上被评论出来的。主人

            // For more information on Bundling, visit https://go.microsoft.com/fwlink/?LinkID=303951
        public static void RegisterBundles(BundleCollection bundles)
        {
    
            bundles.Add(new ScriptBundle("~/bundles/jquery")
                            .Include("~/Scripts/jquery-3.3.1.js")
                            .Include("~/Scripts/jquery-3.3.1.min.js"));
    
            bundles.Add(new ScriptBundle("~/bundles/bootstrap")
                .Include("~/Scripts/bootstrap.js")
                .Include("~/Scripts/bootstrap.min.js"));
    
            bundles.Add(new ScriptBundle("~/bundles/WebFormsJs").Include(
                            "~/Scripts/WebForms/WebForms.js",
                            "~/Scripts/WebForms/WebUIValidation.js",
                            "~/Scripts/WebForms/MenuStandards.js",
                            "~/Scripts/WebForms/Focus.js",
                            "~/Scripts/WebForms/GridView.js",
                            "~/Scripts/WebForms/DetailsView.js",
                            "~/Scripts/WebForms/TreeView.js",
                            "~/Scripts/WebForms/WebParts.js"));
    
            // Order is very important for these files to work, they have explicit dependencies
            bundles.Add(new ScriptBundle("~/bundles/MsAjaxJs").Include(
                    "~/Scripts/WebForms/MsAjax/MicrosoftAjax.js",
                    "~/Scripts/WebForms/MsAjax/MicrosoftAjaxApplicationServices.js",
                    "~/Scripts/WebForms/MsAjax/MicrosoftAjaxTimer.js",
                    "~/Scripts/WebForms/MsAjax/MicrosoftAjaxWebForms.js"));
    
            // Use the Development version of Modernizr to develop with and learn from. Then, when you’re
            // ready for production, use the build tool at https://modernizr.com to pick only the tests you need
            bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                            "~/Scripts/modernizr-*"));
            bundles.Add(new ScriptBundle("~/bundles/popper").Include(
                           "~/Scripts/umd/popper.min.js"));
        }
    
        <asp:ScriptManager runat="server">
            <Scripts>
                <%--To learn more about bundling scripts in ScriptManager see https://go.microsoft.com/fwlink/?LinkID=301884 --%>
                <%--Framework Scripts--%>
                <%--<asp:ScriptReference Name="jquery" />
                <asp:ScriptReference Name="bootstrap" />--%>
    

    想知道VS推荐的方法,因为我不喜欢依赖CDN。非常感谢。

    0 回复  |  直到 7 年前