Home Dashboard Directory Help
Search

In ASP.NET Web Application Visual Basic the RequiredFieldValidator does't work by Виктор Зиборов


Status: 

Closed
 as By Design Help for as By Design


13
0
Sign in
to vote
Type: Bug
ID: 735928
Opened: 4/8/2012 3:11:55 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
1
Workaround(s)
view
8
User(s) can reproduce this bug

Description

Browser gets:
"Server Error in '/' Application.
WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery(case-sensitive). "
Details
Sign in to post a comment.
Posted by César Campos on 1/22/2014 at 9:26 AM
The way you could disable the Unobstrusive validation mode is with the line:

    <appSettings>
        ...
        ...

     <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
    </appSettings>
Posted by Trapulo on 10/23/2012 at 8:47 AM
Ok, but if I reference jquery using bundling?

bundles.Add(New ScriptBundle("~/bundles/jquery", "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js").Include(
                 "~/Scripts/jquery-{version}.js"))

the validator will load a second reference to jquery and block the page!
Posted by dotBomb on 9/6/2012 at 6:34 PM
Also experiencing the same issue with an Express Web 11 solution upgraded to 2012 RC version. Here is my web.config:


<?xml version="1.0"?>

<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->

<configuration>
    <connectionStrings>
        <add name="EventsConnectionString" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Events.mdf;Integrated Security=True"
            providerName="System.Data.SqlClient" />
    </connectionStrings>
    <appSettings>
     <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
     <!--<add key="ValidationSettings:UnobtrusiveValidationMode" value="WebForms" />-->
    </appSettings>
    <system.web>
     <authorization>
        <deny users="?" />
     </authorization>
     <roleManager enabled="true" />
     <authentication mode="Forms" />
     <compilation debug="true" targetFramework="4.5" />
     <httpRuntime requestValidationMode="4.5" targetFramework="4.5" encoderType="System.Web.Security.AntiXss.AntiXssEncoder, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     <pages controlRenderingCompatibilityVersion="4.5" />
     <machineKey compatibilityMode="Framework45" />
     <siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
        <providers>
         <clear />
         <add name="XmlSiteMapProvider"
             description="Default SiteMap Provider"
             type="System.Web.XmlSiteMapProvider"
             siteMapFile="Web.sitemap"
             securityTrimmingEnabled="true" />
        </providers>
     </siteMap>
    </system.web>

</configuration>
Posted by Rifad on 8/23/2012 at 10:58 AM
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
    <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime targetFramework="4.5"/>
</system.web>
</configuration>

The above is my webconfig file,I dont have
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="WebForms" /> line in my web config file and i am still getting the error.

Posted by Microsoft on 4/9/2012 at 7:51 PM
When targeting .NET 4.5 we enable Unobtrusive Validation 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" />

The templates in the RC milestone will have all of this wired up automatically for you.
Posted by MS-Moderator07 [Feedback Moderator] on 4/8/2012 at 11:41 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by MS-Moderator01 on 4/8/2012 at 6:47 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by Rinzler on 9/12/2012 at 6:31 AM
Hi,

After upgrading to .NET 4.5, I got this error when using ASP Validation Controls. I don't have the following line in my web.config (<add key="ValidationSettings:UnobtrusiveValidationMode" value="WebForms" />), so deleting it wasn't a solution.

Adding a ScriptResourceDefinition did work for me:
1. Add global.asax item in your project
2. Add following code to 'Application_Start'
        Dim myScriptResDef As New ScriptResourceDefinition()
        myScriptResDef.Path = "~/JS/jquery-1.8.1.js"
        myScriptResDef.DebugPath = "~/JS/jquery-1.8.1.js"
        myScriptResDef.CdnPath = "http://code.jquery.com/jquery-1.8.1.js"
        myScriptResDef.CdnDebugPath = "http://code.jquery.com/jquery-1.8.1.js"
        ScriptManager.ScriptResourceMapping.AddDefinition("jquery", Nothing, myScriptResDef)
3. Edit the relative paths to where the jquery javascript file is located in your project.
4. Try again and see if this helped.

PS: The debug path is for when you are debugging, the CDN paths are used for Content Delivery Networks. So if you're not debugging or not deploying(and/or debuggin) in a CDN environment, you can leave those out.

Source:
http://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanager.scriptresourcemapping.aspx