π Introduction
While working with ASP.NET Web Forms, many beginners face the following error when running their project:
WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery (case-sensitive).
This error usually appears when:
You use validation controls like RequiredFieldValidator
jQuery is not properly configured
You create a new Web Forms project
You update Visual Studio
In this article, we will understand:
This guide is written in easy language for beginners.
β Why This Error Occurs
ASP.NET Web Forms uses something called:
π Unobtrusive Validation
Unobtrusive validation depends on:
If jQuery is not registered correctly in the project, ASP.NET cannot find it and shows this error.
In simple words:
π ASP.NET wants jQuery
π jQuery is missing
π So it throws an error
π§ͺ Example Scenario
Suppose you add this control in your page:
<asp:RequiredFieldValidator
ID="rfvName"
runat="server"
ControlToValidate="txtName"
ErrorMessage="Name is required">
</asp:RequiredFieldValidator>
When you run the project, instead of loading the page, you see the error message.
π Solution 1 β Quick & Easy Fix (Best for Beginners)
This solution disables unobtrusive validation.
β
Step 1: Open Web.config
Go to:
YourProject β Web.config
β
Step 2: Add This Code Inside <appSettings>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
If <appSettings> does not exist, create it.
β
Step 3: Save and Run
Press:
Ctrl + F5
π Output
β Before Fix
Application shows:
WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'
Page does not load.
β
After Fix
β Page loads successfully
β Validation works
β No error appears
π Solution 2 β Professional Method (Register jQuery Properly)
If you want to keep client-side validation enabled, follow this method.
β
Step 1: Make Sure jQuery Exists
Check inside your project:
Scripts folder
You should have:
jquery-3.7.0.min.js
If not, download it from the official jQuery website and add it to Scripts folder.
β
Step 2: Open Global.asax.cs
Go to:
YourProject β Global.asax.cs
Inside Application_Start(), add:
protected void Application_Start(object sender, EventArgs e)
{
ScriptManager.ScriptResourceMapping.AddDefinition("jquery",
new ScriptResourceDefinition
{
Path = "~/Scripts/jquery-3.7.0.min.js",
DebugPath = "~/Scripts/jquery-3.7.0.js"
});
}
β
Step 3: Save and Run
Now run the project again.
π― Important Notes
This error happens only in ASP.NET Web Forms
It does NOT happen in ASP.NET Core
Always check if jQuery exists in Scripts folder
The name βjqueryβ is case-sensitive
π Conclusion
In this article, we learned:
β What UnobtrusiveValidationMode means
β Why the ScriptResourceMapping error occurs
β Two simple ways to fix it
β Step-by-step instructions for beginners
This is a common error in ASP.NET Web Forms, but now you can fix it easily in just a few minutes.
If you found this helpful, share it with other developers who may face the same issue.