ASP.NET validaion summary is use to display summary for validation results. Suppose you have two controls first name and last name and there is a require field validation for each. Now if you add a validation summary, the failed validations will appear in validation summary instead of requirefieldvalidtions.
Validation Summary Example in ASP.NET Example:
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" >
<html>
<body>
<form id="Form1" runat="server">
<h4>
Validation Summary Example</h4>
<br />
Enter First Name:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="TextBox1"
runat="server" ErrorMessage="Please Enter First Name" InitialValue="" Text="*" />
<br />
Enter Last Name:
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="TextBox2"
runat="server" ErrorMessage="Please Enter Last Name" InitialValue="" Text="*" />
<br />
<asp:Button ID="Button1" Text="Submit" runat="server" />
<br />
<br />
<asp:ValidationSummary ID="ValidationSummary1" HeaderText="You must enter a value in the following fields:"
DisplayMode="BulletList" EnableClientScript="true" runat="server" />
</form>
</body>
</html>
No comments:
Post a Comment