ASP.net RequiredFieldValidator VisualStudio 2012

前端之家收集整理的这篇文章主要介绍了ASP.net RequiredFieldValidator VisualStudio 2012前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在用ASP.net c#开发一个项目.
我想要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>

哪个会为你禁用它.

或者,您可以将这样的内容添加到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"
});

希望这能让你平仓!

原文链接:https://www.f2er.com/aspnet/247018.html

猜你在找的asp.Net相关文章