C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
ASP.NET ValidationSummary ControlThis validator is used to display list of all validation errors in the web form. It allows us to summarize the error messages at a single location. We can set DisplayMode property to display error messages as a list, bullet list or single paragraph. ValidationSummary PropertiesThis control has following properties.
ExampleThe following example explains how to use ValidationSummery control in the application. // ValidationSummeryDemo.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ValidationSummeryDemo.aspx.cs" Inherits="asp.netexample.ValidationSummeryDemo" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> </div> <table class="auto-style1"> <tr> <td class="auto-style2">User Name</td> <td> <asp:TextBox ID="username" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="user" runat="server" ControlToValidate="username" ErrorMessage="Please enter a user name" ForeColor="Red">*</asp:RequiredFieldValidator> </td> </tr> <tr> <td class="auto-style2">Password</td> <td> <asp:TextBox ID="password" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="pass" runat="server" ControlToValidate="password" ErrorMessage="Please enter a password" ForeColor="Red">*</asp:RequiredFieldValidator> </td> </tr> <tr> <td class="auto-style2"> <br/> <asp:Button ID="Button1" runat="server"Text="login"/> </td> <td> <asp:ValidationSummary ID="ValidationSummary1" runat="server" ForeColor="Red"/> <br/> </td> </tr> </table> </form> </body> </html> Output: It produces the following output when view in the browser. It throws error summary when user login without credentials.
Next TopicMVC Tutorial
|