ValidationSummary in asp.net

InfoPath alternatives for form designing SharePoint

In this post, we will discuss ValidationSummary in asp.net.

You can also check my previous articles on RequiredFieldValidator, RangeValidator, RegularExpressionValidator examples in Asp.Net.

ValidationSummary shows all the messages as summery.

Check out the full code here:

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”ValidatorExamples.aspx.cs”
Inherits=”ValidatorExamples” %>

<!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 runat=”server”>
<title>RegularExpressionValidator example in Asp.Net</title>
</head>
<body>
<form id=”form1″ runat=”server”>
<div>
<asp:ValidationSummary ID=”ValidationSummary1″ runat=”server” ShowMessageBox=”false”
ShowSummary=”true” ForeColor=”Red” />
Enter First Name:<asp:TextBox ID=”txtFirstName” runat=”server”></asp:TextBox><br />
<asp:RequiredFieldValidator ID=”RequiredFieldValidator1″ runat=”server” ForeColor=”Red”
ErrorMessage=”Enter First Name!” ControlToValidate=”txtFirstName” Text=”*”></asp:RequiredFieldValidator><br />
Enter EmailID:<asp:TextBox ID=”txtEmailID” runat=”server”></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID=”RequiredFieldValidator2″ runat=”server” ForeColor=”Red”
ErrorMessage=”Enter Email ID!” ControlToValidate=”txtEmailID” Text=”*”></asp:RequiredFieldValidator><br />
<br />
<asp:Button ID=”btnSubmit” runat=”server” Text=”Submit” />
</div>
</form>
</body>
</html>

Here the main properties are:
ShowMessageBox:
If ShowMessageBox is true then the error message will show in Dialogbox like below:



ShowSummary:
If ShowSummary is True then the error message will show as summery like below:


You May Also like the Following SharePoint Online Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →

Leave a Reply