错误:0x800a138f - Microsoft JScript 运行时错误:无法获取属性“unobtrusive”的值:对象为空或未定义
底部列出的 Index.cshtml 是我出现问题的地方。
BundleConfig.cs:
using System.Web;
using System.Web.Optimization;
namespace MyWebMVC
{
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
"~/Scripts/jquery-ui-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate*",
"~/Scripts/jquery.unobtrusive*"
));
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/site.css"));
bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
"~/Content/themes/base/jquery.ui.core.css",
"~/Content/themes/base/jquery.ui.resizable.css",
"~/Content/themes/base/jquery.ui.selectable.css",
"~/Content/themes/base/jquery.ui.accordion.css",
"~/Content/themes/base/jquery.ui.autocomplete.css",
"~/Content/themes/base/jquery.ui.button.css",
"~/Content/themes/base/jquery.ui.dialog.css",
"~/Content/themes/base/jquery.ui.slider.css",
"~/Content/themes/base/jquery.ui.tabs.css",
"~/Content/themes/base/jquery.ui.datepicker.css",
"~/Content/themes/base/jquery.ui.progressbar.css",
"~/Content/themes/base/jquery.ui.theme.css"));
}
}
}
_rootLayout.cshtml:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta name="viewport" content="width=device-width" />
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
<link href="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Content/css")" rel="stylesheet" type="text/css" />
<script src="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Scripts/js")" type="text/javascript"></script>
@Html.DevExpress().GetStyleSheets(
new StyleSheet { ExtensionSuite = ExtensionSuite.NavigationAndLayout },
new StyleSheet { ExtensionSuite = ExtensionSuite.Editors },
new StyleSheet { ExtensionSuite = ExtensionSuite.HtmlEditor },
new StyleSheet { ExtensionSuite = ExtensionSuite.GridView },
new StyleSheet { ExtensionSuite = ExtensionSuite.PivotGrid },
new StyleSheet { ExtensionSuite = ExtensionSuite.Chart },
new StyleSheet { ExtensionSuite = ExtensionSuite.Report },
new StyleSheet { ExtensionSuite = ExtensionSuite.Scheduler }
)
@Html.DevExpress().GetScripts(
new Script { ExtensionSuite = ExtensionSuite.NavigationAndLayout },
new Script { ExtensionSuite = ExtensionSuite.HtmlEditor },
new Script { ExtensionSuite = ExtensionSuite.GridView },
new Script { ExtensionSuite = ExtensionSuite.PivotGrid },
new Script { ExtensionSuite = ExtensionSuite.Editors },
new Script { ExtensionSuite = ExtensionSuite.Chart },
new Script { ExtensionSuite = ExtensionSuite.Report },
new Script { ExtensionSuite = ExtensionSuite.Scheduler }
)
</head>
<body>
@Html.DevExpress().Splitter(settings => {
settings.Name = "MainSplitter";
settings.AllowResize = false;
settings.Orientation = System.Web.UI.WebControls.Orientation.Vertical;
settings.FullscreenMode = true;
settings.SeparatorVisible = false;
settings.Styles.Pane.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
settings.Styles.Pane.Paddings.Padding = System.Web.UI.WebControls.Unit.Pixel(0);
settings.Panes.Add(pane => {
pane.Name = "Header";
//pane.ScrollBars = System.Web.UI.WebControls.ScrollBars.Auto;
pane.Size = System.Web.UI.WebControls.Unit.Pixel(140);
pane.MinSize = System.Web.UI.WebControls.Unit.Pixel(83);
pane.PaneStyle.BorderBottom.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);
pane.PaneStyle.CssClass = "headerPane";
pane.SetContent(() => {
Html.RenderPartial("HeaderPartialView");
});
});
settings.Panes.Add(pane => {
pane.Name = "Content";
pane.PaneStyle.CssClass = "mainContentPane";
pane.MinSize = System.Web.UI.WebControls.Unit.Pixel(375);
pane.PaneStyle.BackColor = System.Drawing.Color.White;
pane.PaneStyle.BorderBottom.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);
pane.SetContent(RenderBody().ToHtmlString());
pane.ScrollBars = System.Web.UI.WebControls.ScrollBars.Auto;
});
settings.Panes.Add(pane => {
pane.Name = "Footer";
pane.Size = System.Web.UI.WebControls.Unit.Pixel(25);
pane.PaneStyle.CssClass = "footerPane";
pane.SetContent(() => {
Html.RenderPartial("FooterPartialView");
});
});
Scripts.Render("~/bundles/jqueryval");
Scripts.Render("~/bundles/jquery");
}).GetHtml()
</body>
</html>
_mainLayout.cshtml:
@{ Layout = "~/Views/Shared/_rootLayout.cshtml"; }
@Html.DevExpress().Splitter(settings => {
settings.Name = "ContentSplitter";
settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
settings.Height = System.Web.UI.WebControls.Unit.Percentage(100);
settings.Styles.Pane.Paddings.Padding = System.Web.UI.WebControls.Unit.Pixel(0);
settings.Styles.Pane.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
settings.Panes.Add(subpane => {
subpane.Name = "ContentCenter";
subpane.PaneStyle.CssClass = "contentPane";
subpane.Separator.Visible = DevExpress.Utils.DefaultBoolean.True;
subpane.ScrollBars = System.Web.UI.WebControls.ScrollBars.Auto;
subpane.Separator.SeparatorStyle.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);
subpane.Separator.SeparatorStyle.BorderTop.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
subpane.SetContent(RenderBody().ToHtmlString());
});
}).GetHtml()
Index.cshtml:(这是我的脚本出错的地方)
<link rel="stylesheet" type="text/css" href="@Url.Content("~/Content/Docking/CSS/Widgets.css")" />
<script type="text/javascript">
function displaySuccess(result) {
popup.Show();
}
function PrepareValidationScripts(form) {
if (!form)
return;
if (form.attr("data-executed"))
return;
$.validator.unobtrusive.parse(form); // <----- this is where I get the error
form.attr("data-executed", "true");
}
</script>
@{
//this is where I render my partial views
<snip.....>
<snip.....>
<snip.....>
}