Use Unobtrusive Validation in .NET 4.5 WebForms Site or Application with the ScriptManager
Environment
Product | Progress® Telerik® UI for ASP.NET AJAX |
Description
When you create a .NET 4.5 WebForms Site, it comes with a jQuery library that is already registered with the ScriptManager as jquery
. The unobtrusive validation will work as long as the standard asp:ScriptManager
control is used. How can I use unobtrusive validation in a .NET 4.5 WebForms site or application with the ScriptManager?
Cause
The Telerik controls bring their own specific version of jQuery and the ScriptManager control registers that version as jquery
after removing all registrations with the same name. As a result, when you replace the asp:ScriptManager
with a RadScriptManager
, the initial jquery
registration will be removed and the unobtrusive validation will not find it.
Solution
To solve this issue, ensure that only one version of jQuery is used in the website and that you register it so that the unobtrusive validation can locate it:
-
Set the
EnableEmbeddedjQuery
property of theRadScriptManager
tofalse
to disable the jQuery that is embedded inTelerik.Web.UI
. Thus, the removal of thejquery
registration that comes with the website project is prevented. -
Open TOOLS > Library Package Manager > Package Manager Console. Uninstall and unregister the jQuery version that is provided with the Visual Studio template by running the
PM> Uninstall-Package AspNet.ScriptManager.jQuery -Version x.x.x
command. Note thatx.x.x
is the jQuery version that comes installed with the website. -
Install and register the jQuery version that is specific for your current Telerik controls version by running the
PM> Install-Package AspNet.ScriptManager.jQuery -Version x.x.x
command in the Package Manager Console. Note thatx.x.x
is the jQuery version that comes with the Telerik controls.You can still install a different version from the one included in the Telerik controls. However, this approach is not tested by the team and full compatibility cannot be guaranteed.