Except for the required jquery ScriptResourceDefinition in Global.asax (use your own paths):
protected void Application_Start(object sender, EventArgs e) { ScriptManager.ScriptResourceMapping.AddDefinition( "jquery", new ScriptResourceDefinition { Path = "/static/scripts/jquery-1.8.3.min.js", DebugPath = "/static/scripts/jquery-1.8.3.js", CdnPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.3.min.js", CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.3.js", CdnSupportsSecureConnection = true, LoadSuccessExpression = "jQuery" }); }
In addition, you only need to explicitly add "WebUIValidation.js" after the "jquery" ScriptReference in the ScriptManager (the most important part):
<asp:ScriptManager runat="server" EnableScriptGlobalization="True" EnableCdn="True"> <Scripts> <asp:ScriptReference Name="jquery" /> <asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" /> </Scripts> </asp:ScriptManager>
If you add it before jquery, or if you don’t add either or both of them at all ( ASP.Net will automatically add it before jquery), the client check will be completely violated: / p>
http://connect.microsoft.com/VisualStudio/feedback/details/748064/unobtrusive-validation-breaks-with-a-script-manager-on-the-page
You do not need any of these NuGet packages at all, nor additional ScriptReference (some of them are just duplicates or even completely unnecessary bells and whistles), since they are automatically added by ASP.Net if necessary) on your blog.
EDIT: you do not need to explicitly add "WebForms.js" (removed from the example) - and if you do, its LoadSuccessExpression will be ignored for any reason
Nikola Bogdanović Jul 22 2018-11-22T00: 00Z
source share