ASP.net RequiredFieldValidator VisualStudio 2012

I am developing a project with ASP.net C #. I want RequiredFieldValidator to check my text box. I add a validator, and it works fine in Visual Studio 2010. But once I did the same, it just doesn't work in Visual Studio 2012. I get this error:

[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 

Yours faithfully...

+6
source share
3 answers

Look here

It looks like you need to either delete this line:

 <appSettings> <add key="ValidationSettings:UnobtrusiveValidationMode" value="WebForms" /> </appSettings> 

Or change it to this:

 <appSettings> <add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/> </appSettings> 

This will disable it for you.

Alternatively, you can add something like this to your 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" }); 

Hope this helps you hide!

+16
source
 protected void Page_Load(object sender, EventArgs e) { this.UnobtrusiveValidationMode =System.Web.UI.UnobtrusiveValidationMode.None; } 

Just copy and paste the c # code

+4
source
 <appSettings> <add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/> </appSettings> 

never use jquery script it will go to the server every time, which adversely affects the performance of your application, just add the tag (mentioned above) in the web configuration

in configuration tag

-2
source

All Articles