VB.net Tutorials with Examples

VB.Net Projects

VB.Net Project 1

adplus-dvertising
Validation Summary control
Previous Home Next

This control is used to display the list of all the validation error that has occurred on the page. The error message displayed is the one set for the ErrorMessage attribute of the validation control. No error message will be displayedif this attribute is not set.

ASP.NET has provided an additional control that complements the validator controls .The validation summary control will collect all the error messages of all the non-valid controls and put them in a tidy list. The list can be either shown on the web page (as shown in the example above) or with a popup box (by specifying ShowMessageBox="True")..

DisplayMode: has three options List, BulletList, and, SingleParagraph.

ShowMessageBox: when set to true will display the error as a alert popup.

ShowSummary: will display the error on the page. By default it is true.

.ASPX CODE

<%@ Page 
Language="VB" 
AutoEventWireup="true" 
CodeFile="Default4.aspx.vb" 
Inherits="Default4" %>
<!DOCTYPE html PUBLIC "
-//W3C//
DTD XHTML 1.0 
Transitional//EN" "http:
//www.w3.org/TR/xhtml1/DTD/
xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1"
 runat="server">
<title>Untitled Page
</title>
<style 
type="text/css">
.style1
{
width: 52%;
border-left-style: solid;
border-left-width: 1px;
border-right: 1px solid 
			#C0C0C0;
border-top-style: solid;
border-top-width: 1px;
border-bottom: 1px solid 
			#C0C0C0;
background-color: #008000;
}
.style2
{
color: #FFFFFF;
}
.style3
{
width: 126px;
}
</style>
</head>
<body>
<form id
="form1" runat="server">
<div>

<table class="style1">
<tr>
<td class
="style2" colspan
="2">
&nbsp;
 Regular&nbsp; Expression Validator
 &nbsp;</td>
<tr>
<td class
="style2">
Email ID</td>
<td class
="style3"><
asp:TextBox ID="TextBox1" runat
="server"></
asp:TextBox
></td>
<td><
asp:RegularExpressionValidator ID=
"RegularExpressionValidator1" runat="server" 
ControlToValidate="TextBox1" ErrorMessage="plese enter email ID" 
ToolTip="plese Enter email id" 
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">
</asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class=
"style2">
Name</td>
<td class=
"style3">
<asp:TextBox
 ID="TextBox2" 
 runat="server"></
 asp:TextBox>
</td>
<td>
<
asp:RequiredFieldValidator ID=
"RequiredFieldValidator1" runat="server" 
ControlToValidate="TextBox2"
ErrorMessage="Blank not Allowed" 
SetFocusOnError="True"
></asp:RequiredFieldValidato
r>
</td>
</tr>
<tr>
<td class="style2">
Age</td>
<td class="style3">
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</td>
<td>
<asp:RangeValidator ID="RangeValidator1" runat="server" 
ControlToValidate="TextBox3"
ErrorMessage="Age should be  Between !8 to 35" 
MaximumValue="35" 
MinimumValue="18"></asp:RangeValidator>
</td>
</tr>
<tr>
<td class="style2">
&nbsp;</td>
<td class="style3">
<asp:Button ID="Button1" runat="server" 
onclick="Button1_Click" Text="Button" Width="123px" />
</td>
<td>
<asp:ValidationSummary ID="ValidationSummary1"
runat="server" 
ShowMessageBox="True" ShowSummary="False" />
</td>
</tr>
<tr>
<td class="style2">
&nbsp;</td>
<td class="style3">
&nbsp;</td>
<td>
&nbsp;</td>
</tr>
</table>
</div>
</form>
</body>
</html>

Output:

Previous Home Next