How to Fix UnobtrusiveValidationMode Requires a ScriptResourceMapping Error

πŸ“Œ 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:

  • βœ” Why does this error occurs

  • βœ” When it happens

  • βœ” Two simple solutions

  • βœ” Step-by-step fix

  • βœ” Output before and after fixing

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:

  • jQuery library

  • jQuery validation scripts

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.

  • βœ” Error will be resolved

  • βœ” Client-side validation works

🎯 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.