I was playing with Visual Studio 2012 and I created an empty ASP.Net Web Application, when I tried to add the traditional validator controls to a n
In the Nuget Package manager search for AspNet.ScriptManager.jQuery instead of jquery. THat way you will not have to set the mappings yourself and the project will work with the click of a simple install.
Or disable the Unobtrusive Validation by adding this line to the Configuration tag of the web.config file in the project.
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
Add a reference to Microsoft.JScript
in your application in your web.config
as below :
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="Microsoft.JScript, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>
</compilation>
<httpRuntime targetFramework="4.5"/>
</system.web>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="none"/>
</appSettings>
</configuration>
This is the official Microsoft answer from the MS Connect forums. I am copying the relevant text below :-
When targeting .NET 4.5 Unobtrusive Validation is enabled by default. You need to have jQuery in your project and have something like this in Global.asax to register jQuery properly:
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"
});
Replacing the version of jQuery with the version you are using.
You can also disable this new feature in web.config by removing the following line:
<add key="ValidationSettings:UnobtrusiveValidationMode" value="WebForms" />
It seems like there is a lot of incorrect information about the ValidationSettings:UnobtrusiveValidationMode value. To Disable it you need to do the following.
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
The word None, not WebForms should be used to disable this feature.
All the validator error has been solved by this
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
Error must be vanished enjoy....
I suggest to instead this lines
<div>
<asp:TextBox runat="server" ID="username" />
<asp:RequiredFieldValidator ErrorMessage="The username is required" ControlToValidate="username" runat="server" Text=" - Required" />
</div>
by this line
<div>
<asp:TextBox runat="server" ID="username" required />
</div>