In this tutorial i am going to share with you solution of Unobtrusive Validation Error. or also explain how to fix unobtrusive validation error in asp.net.
While you working with Visual Studio 2012, 2013, 2015 etc you may face Unobtrusive Validation Error. The newer version of the visual studio provide some of the new validation features including Unobtrusive Validation. To enable this kind of validation you had to configure your web application.
Generally, there are three ways to enable the Unobtrusive Validation in your Website.
1). By using Global.asax file
2). By using Page_Load event
3). By using Web.Config file
NOTE: If you will choose second option which is Page_Load event than you need to write code on each and every page.
So, Let's discuss solution of unobtrusive validation.
Method 1: By using Global.asax file
If you will choose this way to fix unobtrusive validation error than In the Global.asax file, first you need to add the namespace.
<%@ Import Namespace="using System.Web.UI" %>
After adding the namespace write the following code in the Application_Start method:
<%@ Application Language="C#" %> <%@ Import Namespace="using System.Web.UI" %> <script runat="server"> void Application_Start(object sender, EventArgs e) { // Code that runs on application startup ValidationSettings.UnobtrusiveValidationMode = UnobtrusiveValidationMode.None; } </script>
Method 2: By using Page_Load event
If you will choose this way to fix unobtrusive validation error than you need to write following code into Page_Load event for each and every page.
public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { this.UnobtrusiveValidationMode = System.Web.UI.UnobtrusiveValidationMode.None; } }
Method 3: By using Web.Config file
If you will choose this way to fix unobtrusive validation error then you need to write following code into Web.Config in between <configuration> tag.
<configuration> <appSettings> <add key="ValidationSettings:UnobtrusiveValidationMode" value="None"></add> </appSettings> </configuration>
Error Demo:
If you have any kind of question about any post, Feel free to ask.You can simply drop a comment below post. Your feedback and suggestions will be highly appreciated. ConversionConversion EmoticonEmoticon