Tuesday, November 25, 2014

Enabling Unobtrusive Validation Mode in ASP.NET

Microsoft Visual Studio 2013 provides new Validation features which is include Unobtrusive Validation. Whenever you need to work with such type of Validation mode you will have to firstly configure your Web Application.

How to configure your Web.Config File

< configuration >
< appSettings >
< add key="ValidationSettings:UnobtrusiveValidationMode" value="None" >
< /appSettings >
< system.web >
< compilation debug="true" targetFramework="4.5" />
< httpRuntime targetFramework="4.5" />
< /system.web >
< /configuration >



How to configure your .aspx File

< asp:TextBox runat="server" ID="txt" />
< asp:RequiredFieldValidator ID="RequiredFieldValidator1" ErrorMessage="txt is required" ControlToValidate="txt" runat="server" Text="Text is Required" Display="Dynamic" />
< asp:Button ID="Button1" Text="Submit" runat="server" />