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

2 posts, 0 answers
  1. Telerik Admin
    Telerik Admin avatar
    1696 posts
    Member since:
    Oct 2004

    Posted 21 Dec 2012 Link to this post

    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: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:
  2. Telerik Admin
    Telerik Admin avatar
    1696 posts
    Member since:
    Oct 2004

    Posted 18 Nov 2014 Link to this post

    The following help article contains more detailed information about configuring Unobtrusive Validation with the latest version of UI for ASP.NET AJAX:
Back to Top