我正在用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
致以我的问候…
解决方法
见
here
看起来您必须删除此行:
<appSettings> <add key="ValidationSettings:UnobtrusiveValidationMode" value="WebForms" /> </appSettings>
或者将其更改为:
<appSettings> <add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/> </appSettings>
哪个会为你禁用它.
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" });
希望这能让你平仓!