VALIDATION SUMMARY
we can display validation messages as bulleted list, single paragraph or only list based on DisplayMode. we can set a header text for validation summary.
First - Add New - WebForm - Select Validation Controls Required - Next-Select - Validation Summary
Next - Select Compare Validation - Set Property & setfocusError=True
Next - Select Compare Validation - Set Property & setfocusError=True
Next - Select Required Validation - Set Property & setfocusError=True
Next - Validation Summary Does not Change Anything
Give to Valid Entries Does Not Show Error PopUp
Next - Press F5 run the program - Enter the Invalid Values - Show Error Message related Validation Expressions - last enter Save Button Validation summary Error Message Show
The ValidationSummary control does not perform any validation but shows a summary of all errors in the page.
The summary displays the values of the ErrorMessage property of all validation controls that failed validation.
DEMO
DEMO
Html Coding
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr><td>
<asp:Label ID="Label2" runat="server" Text="Email ID"></asp:Label>
</td><td>
<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server" ControlToValidate="txtEmail"
ErrorMessage="Invalid Email ID"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
SetFocusOnError="True"></asp:RegularExpressionValidator>
</td></tr>
<tr><td>
<asp:Label ID="Label1" runat="server" Text="Password"></asp:Label>
</td><td>
<asp:TextBox ID="txtPassword" runat="server"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1"
runat="server" ControlToCompare="txtConfirmPassword"
ControlToValidate="txtPassword" SetFocusOnError="True"></asp:CompareValidator>
</td></tr>
<tr><td>
<asp:Label ID="Label3" runat="server" Text="Confirm Password"></asp:Label>
</td><td>
<asp:TextBox ID="txtConfirmPassword" runat="server"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator2"
runat="server" ControlToCompare="txtPassword"
ControlToValidate="txtConfirmPassword"
ErrorMessage="Password Not Same" SetFocusOnError="True"></asp:CompareValidator>
</td></tr>
<tr><td>
<asp:Label ID="Label4" runat="server" Text="Country"></asp:Label>
</td><td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ControlToValidate="TextBox1"
ErrorMessage="Fill Country Name" SetFocusOnError="True"></asp:RequiredFieldValidator>
</td></tr>
<tr><td colspan="2">
<asp:Button ID="Button1" runat="server" Text="Save" />
</td></tr>
</table>
</div>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
</form>
</body>
</html>
we can display validation errors summary inline of a web page or a message box or both by using ShowMessageBox and ShowSummary property value true or false.
The following two mutually inclusive properties list out the error message:
- ShowSummary: shows the error messages in specified format.
- ShowMessageBox: shows the error messages in a separate window.
we can display validation messages as bulleted list, single paragraph or only list based on DisplayMode. we can set a header text for validation summary.
First - Add New - WebForm - Select Validation Controls Required - Next-Select - Validation Summary
First Select - Regular Expression Validation - Set Property & setfocusError=True
Next - Select Compare Validation - Set Property & setfocusError=True
Next - Select Compare Validation - Set Property & setfocusError=True
Next - Select Required Validation - Set Property & setfocusError=True
Next - Validation Summary Does not Change Anything
Give to Valid Entries Does Not Show Error PopUp
Next - Press F5 run the program - Enter the Invalid Values - Show Error Message related Validation Expressions - last enter Save Button Validation summary Error Message Show
0 comments:
Post a Comment