This is a migrated thread and some comments may be shown as answers.

ASP.NET 4.5 Unobtrusive Validation and RadControls for ASP.NET AJAX

3 Answers 405 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Telerik Admin
Top achievements
Rank 1
Iron
Telerik Admin asked on 21 Dec 2012, 03:02 PM
When using ASP.NET 4.5 and you have some ASP validation controls on the page together with a postback control from the RadControls for ASP.NET AJAX suite, the following exception will be thrown:

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

This can be reproduced with the following simple markup:
<telerik:RadScriptManager runat="server" ID="ScriptManager1">
</telerik:RadScriptManager>
 
<telerik:RadComboBox runat="server" ID="ComboBox1"></telerik:RadComboBox>
 
<asp:Button ID="Button1" runat="server" Text="Submit" />
<asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ErrorMessage="Choose a destination first" ControlToValidate="ComboBox1" />

According to Microsoft, unobtrusive validation is the new way ASP.NET net validators work and it by default requires jQuery. We ship jQuery with our controls, but we did not register it the way Microsoft wants before Q3 2012 SP1. Proper resource mapping was added in the Q3 Service Pack 1 release. In the meantime the following steps will allow you to use this feature:

1. Add Global.asax file to the project
2. Put the following code in the Application_Start event:
var def = new ScriptResourceDefinition()
            {
                ResourceName = "Telerik.Web.UI.Common.jQuery.js",
                ResourceAssembly = System.Reflection.Assembly.GetAssembly(typeof(Telerik.Web.UI.RadWebControl))
            };
 
ScriptManager.ScriptResourceMapping.AddDefinition("jquery", def);


NOTE: There is currently a bug in the default ASP ScriptManager that requires jQuery to be the first script registered on the page in order for Unobtrusive Validation to work: http://connect.microsoft.com/VisualStudio/feedback/details/748064/unobtrusive-validation-breaks-with-a-script-manager-on-the-page.

3 Answers, 1 is accepted

Sort by
0
Telerik Admin
Top achievements
Rank 1
Iron
answered on 18 Nov 2014, 01:54 PM
The following help article contains more detailed information about configuring Unobtrusive Validation with the latest version of UI for ASP.NET AJAX: http://www.telerik.com/help/aspnet-ajax/introduction-troubleshooting-jquery.html
0
Michael Ash
Top achievements
Rank 1
answered on 15 Sep 2018, 04:46 PM

Converted web project in VS2017 from RadControls 2016.3.914.40 to 2018.1.117 this AM.
Got an error when running main page from VS2017 in IE11:

ASP.NET 4.5 Unobtrusive Validation and RadControls for ASP.NET AJAX:

I used the fix here to Global.asax (https://www.telerik.com/forums/asp-net-4-5-unobtrusive-validation-and-radcontrols-for-asp-net-ajax)
However, now I'm getting error on startup:

Webresource.axd $telerik.$ = jQuery.noConflict(true); '$telerik' is undefined after correcting global.asax.
Reverted back to old version with no problems.
Is there a workaround?

0
Vessy
Telerik team
answered on 19 Sep 2018, 03:20 PM
Hi Michael,

It seems that the Unobtrusive Validation jquery is loaded after the one shipped by us and is rewriting it, respectively. Can you, please, try the suggestions from the following help article (if you have not done it already) and see if the result will be the same?
https://docs.telerik.com/devtools/aspnet-ajax/general-information/troubleshooting/jquery-troubleshooting

Looking forward to your reply,
Vessy
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
Telerik Admin
Top achievements
Rank 1
Iron
Answers by
Telerik Admin
Top achievements
Rank 1
Iron
Michael Ash
Top achievements
Rank 1
Vessy
Telerik team
Share this question
or