ValidationSummary Class

Presents a summary of all the validation errors that have occurred on a form.

Namespace: System.Web.UI.MobileControls
Assembly: System.Web.Mobile (in

public class ValidationSummary : MobileControl
public class ValidationSummary extends MobileControl
public class ValidationSummary extends MobileControl
Not applicable.

The ValidationSummary class creates a summary of all validation errors and presents them either inline or on a separate form. The ValidationSummary uses the text in the ErrorMessage property for the errors that are displayed either inline or on a summary form.

Although the ValidationSummary class of the ASP.NET mobile controls mimics the behavior of the Web Forms ValidationSummary class in many ways, the mobile controls version of the class does not inherit directly from the Web Forms version of the class. Thus, properties that modify the output of the validation summary, such as the DisplayMode property, are not available in mobile controls. The mobile controls version of the summary is derived directly from the MobileControl class.

The following code example demonstrates how to create an instance of a ValidationSummary class, and add it to a form in an ASP.NET mobile Web application during a page load. The user-defined Page_Load event handler determines if there is an error, and then either launches the form containing the ValidationSummary, or the congratulatory thank you form.

Security noteSecurity Note:

This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview (Visual Studio).

<%@ Page Language="C#" 
    Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile" 
    Assembly="System.Web.Mobile" %>

<script runat="server">
    private void Page_Load(Object sender, EventArgs e)
        // Define validation expressions.
        UserNameExprValidator.ValidationExpression = 
        PhoneExprValidator.ValidationExpression =
            "((\\(\\d{3}\\) ?)|(\\d{3}-))?\\d{3}-\\d{4}";
        UserNameReqValidator.Text = "User name required";
        UserNameExprValidator.Text = 
            "Must be 2-10 characters";
        PhoneExprValidator.Text = 
            "Requires a valid number: 425-555-0187";
        // ErrorMessages appear in ValidationSummary.
        UserNameExprValidator.ErrorMessage = 
            "User name must be 2-10 characters";
        UserNameReqValidator.ErrorMessage = 
            "User name required";
        PhoneExprValidator.ErrorMessage = 
            "Valid number required: 425-555-0187";

    private void OnCmdClick(Object sender, EventArgs e)
        if (Page.IsValid)
            ActiveForm = Form2;
            ValSummary.BackLabel = "Return to Form";
            ActiveForm = Form3;

<html xmlns="" >
    <mobile:Form runat="server" id="Form1">
        <mobile:Label runat="server" id="HeadingLabel" 
            Text="Provide your name and number" 
            StyleReference="title" />
        <mobile:Label runat="server" id="UserNameLabel" 
            Text="User Name (req'd)" />
        <mobile:Textbox  runat="server" id="UserNameTextBox"/>
        <mobile:RequiredFieldValidator runat="server" 
            ControlToValidate="UserNameTextBox" />
        <mobile:RegularExpressionValidator runat="server" 
            ControlToValidate="UserNameTextBox" />
        <mobile:Label runat="server" id="PhoneLabel" 
            Text="Phone" />
        <mobile:Textbox  runat="server" id="PhoneTextBox"/>
        <mobile:RegularExpressionValidator runat="server" 
            ControlToValidate="PhoneTextBox" />
        <mobile:Command runat="server" id="Cmd1" 
            text="Submit" OnClick="OnCmdClick"/>
    <mobile:Form runat="server" id="Form2" >
        <mobile:Label ID="Label1" runat="server" 
            Text="Thank You." />
    <mobile:Form ID="Form3" Runat="server">
        <mobile:ValidationSummary ID="ValSummary" 
            HeaderText="Error Summary:" 
            runat="server" />

  • AspNetHostingPermission  for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
  • AspNetHostingPermission  for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1