捆绑未定义的Webforms js文件

时间:2018-12-30 11:24:26

标签: c# asp.net bundle

为什么无法识别功能?我已经按照正常的引用样式

的顺序添加了它们

Global.asax

protected void Application_Start(object sender, EventArgs e)
{
    BundleTable.EnableOptimizations = true;
    BundleConfig.RegisterBundles(BundleTable.Bundles);
}

BundleConfig.cs

public static void RegisterBundles(BundleCollection bundles)
{
    bundles.Add(new ScriptBundle("~/bundles/AdminlteJs").Include(
        "~/AdminLTE/plugins/jquery/jquery.min.js",
        "~/AdminLTE/dist/js/adminlte.min.js",
        "~/AdminLTE/plugins/bootstrap/js/bootstrap.bundle.min.js",
        "~/AdminLTE/plugins/datatables/jquery.dataTables.min.js",
        "~/AdminLTE/plugins/datatables/dataTables.bootstrap4.js"
        ));

    bundles.Add(new ScriptBundle("~/bundles/PluginsJs").Include(
        "~/Plugins/js/animsition.min.js",
        "~/Plugins/js/iziModal.min.js",
        "~/Plugins/js/iziToast.min.js",
        "~/Plugins/js/noty.min.js",
        "~/Plugins/FontAwesome/js/all.min.js",
        "~/Plugins/jQueryValidation/dist/jquery.validate.min.js",
        "~/Plugins/jQueryUI/jquery-ui.min.js",
        "~/Plugins/jQueryFileUpload/jquery.fileupload.js"));

    bundles.Add(new ScriptBundle("~/bundles/ScriptsJs").Include(
        "~/Scripts/LoginForm/js/PageAnimation.js",
        "~/Scripts/MasterPage/MenuSelection.js",
        "~/Scripts/MasterPage/Notification.js",
        "~/Scripts/MasterPage/PageTransition.js",
        "~/Scripts/Pages/DataTables.js",
        "~/Scripts/Pages/FileUpload.js",
        "~/Scripts/Pages/Validaion.js"));

}

Bundle.config

<?xml version="1.0"?>

<bundles version="1.0">
  <styleBundle path="~/bundles/AdminLte/css">
    <include path="~/AdminLTE/dist/js/plugins/font-awesome/css/font-awesome.min.css" />
    <include path="~/AdminLTE/dist/css/adminlte.min.css" />
    <include path="~/AdminLTE/plugins/datatables/dataTables.bootstrap4.css" />
  </styleBundle>

  <styleBundle path="~/bundles/Plugins/css">
    <include path="~/Plugins/css/minified/animsition.min.css" />
    <include path="~/Plugins/css/minified/iziModal.min.css" />
    <include path="~/Plugins/css/minified/iziToast.min.css" />
    <include path="~/Plugins/css/noty.css" />
    <include path="~/Plugins/FontAwesome/css/all.min.css" />
  </styleBundle>

  <styleBundle path="~/bundles/Styles/css">
    <include path="~/Styles/LoginForm/css/style.css" />
    <include path="~/Styles/MasterPages/Layout.css" />
    <include path="~/Styles/MasterPages/Loader.css" />
    <include path="~/Styles/MasterPages/PageTransition.css" />
  </styleBundle>

</bundles>

在母版页上

<asp:PlaceHolder runat="server">
    <%: System.Web.Optimization.Styles.Render("~/bundles/AdminLte/css") %>
    <%: System.Web.Optimization.Styles.Render("~/bundles/Plugins/css") %>
    <%: System.Web.Optimization.Styles.Render("~/bundles/Styles/css") %>

    <%: System.Web.Optimization.Scripts.Render("~/bundles/AdminLteJs") %>
    <%: System.Web.Optimization.Scripts.Render("~/bundles/PluginsJs") %>d
<%: System.Web.Optimization.Scripts.Render("~/bundles/ScriptsJs") %>    

</asp:PlaceHolder>

css文件的bundle.config正常工作,但是对于bundleconfig.cs中的JS而言,则不是,许多功能在控制台上未定义错误...

1 个答案:

答案 0 :(得分:0)

好吧,看来我的文件夹结构只是一团糟,我尝试从nuget Manager安装插件,以查看它放置js和css文件的位置,并只是将它们添加到这些文件夹中的捆绑包中,因为某些插件对字体或字体有一些引用。图片等...

此外,将脚本渲染文件放置在标题上也解决了页面无法在母版页上找到功能的问题。