我正在用ASP.net c#开发一个项目.
我想要requiredFieldValidator来检查我的文本框.我正在添加验证器,它在Visual Studio 2010中运行得非常好.但是一旦我做了同样的事情,完全相同的事情,它在Visual Studio 2012中不起作用.我收到这个错误:
我想要requiredFieldValidator来检查我的文本框.我正在添加验证器,它在Visual Studio 2010中运行得非常好.但是一旦我做了同样的事情,完全相同的事情,它在Visual Studio 2012中不起作用.我收到这个错误:
[InvalidOperationException: WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery(case-sensitive).] System.Web.UI.ClientScriptManager.EnsureJqueryRegistered() +2171326 System.Web.UI.WebControls.BaseValidator.RegisterUnobtrusiveScript() +10 System.Web.UI.WebControls.BaseValidator.OnPreRender(EventArgs e) +9576177 System.Web.UI.Control.PreRenderRecursiveInternal() +83 System.Web.UI.Control.PreRenderRecursiveInternal() +168 System.Web.UI.Control.PreRenderRecursiveInternal() +168 System.Web.UI.Control.PreRenderRecursiveInternal() +168 System.Web.UI.Control.PreRenderRecursiveInternal() +168 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint) +974@H_301_5@致以我的问候…
解决方法
见
here
@H_301_5@看起来您必须删除此行:
<appSettings> <add key="ValidationSettings:UnobtrusiveValidationMode" value="WebForms" /> </appSettings>@H_301_5@或者将其更改为:
<appSettings> <add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/> </appSettings>@H_301_5@哪个会为你禁用它. @H_301_5@或者,您可以将这样的内容添加到Global.asax中
ScriptManager.ScriptResourceMapping.AddDefinition("jquery",new ScriptResourceDefinition { Path = "~/scripts/jquery-1.4.1.min.js",DebugPath = "~/scripts/jquery-1.4.1.js",CdnPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.1.min.js",CdnDebugPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.1.js" });@H_301_5@希望这能让你平仓!