Madison C. Brewer Madison C. Brewer - 1 year ago 94
ASP.NET (C#) Question

ASP conundrum (how to resolve)

Okay, so I'm using validation controls on a website

At first I was getting the classic error

WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery(case-sensitive).

Didn't take much to fix that.

I added the following to my web.config file

<add key="ValidationSettings:UnobtrusiveValidationMode" value="none"/>

However, now when I run my pages, my asp:LinkButtons don't work correctly, their code-behind doesn't seem to execute (it's a school assignment so I can merely alter them to anchors. Guidelines mandate asp:LinkButtons).

I tried

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

But then I get the old error and my page won't load.

:/ I'm very confounded. What can I do?

EDIT: something possibly worth noting

My asp linkbuttons only malfunction in pages that also possess asp validators.
My other pages with asp link buttons work just fine.

Answer Source

Using this informative post from the MSDN blog

Add the following to your Global.asax file at the root of your web project:

protected void Application_Start(object sender, EventArgs e)
    string str = "1.7.1"; //Change to the version of jQuery you require
    ScriptManager.ScriptResourceMapping.AddDefinition("jquery", new ScriptResourceDefinition
        Path = "~/Scripts/jquery-" + str + ".min.js", 
        DebugPath = "~/Scripts/jquery-" + str + ".js", 
        CdnPath = "" + str + ".min.js", 
        CdnDebugPath = "" + str + ".js", 
        CdnSupportsSecureConnection = true, 
        LoadSuccessExpression = "window.jQuery"

Place the following in your Master page or on each page that uses the validation controls:

<asp:ScriptManager runat="server">
        <asp:ScriptReference Name="jquery" />
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download