ValidationSummary

in namespace DotVVM.Framework.Controls

Displays all validation messages from the current Validation.Target.

Usage & Scenarios

Displays all validation errors in a list.

Look at the Validation tutorial to see how the validation works.

Sample 1: Basic ValidationSummary

The ValidationSummary will display all validation errors in the validation context.

<dot:TextBox Text="{value: Text}" />

<dot:ValidationSummary />

<dot:Button Text="SEND" Click="{command: Send()}" />
using System.ComponentModel.DataAnnotations;

namespace DotvvmWeb.Views.Docs.Controls.builtin.ValidationSummary.sample1
{
    public class ViewModel
    {
        [Required]
        public string Text { get; set; }

        public void Send()
        {
            // process data
        }
    }
}

Sample 2: Validation erros from child objects

By default, the ValidationSummary control displays errors that comes directly from the Validation.Target object's properties. If the validation target contains another child objects, the validation errors from those objects are not displayed. This is because of performance reasons.

However, using the IncludeErrorsFromChildren property, you can tell the control to display validation errors event from the child objects. Just be careful because there will be a performance penalty if you use this feature on large and compilcated viewmodels.

<dot:TextBox Text="{value: ChildObject.Text}" />

<dot:ValidationSummary IncludeErrorsFromChildren="true" />

<dot:Button Text="SEND" Click="{command: Send()}" />
using System.ComponentModel.DataAnnotations;

namespace DotvvmWeb.Views.Docs.Controls.builtin.ValidationSummary.sample2
{
    public class ViewModel
    {
        public ChildViewModel ChildObject { get; set; } = new ChildViewModel();

        public void Send()
        {
            // process data
        }
    }

    public class ChildViewModel
    {
        [Required]
        public string Text { get; set; }
    }
}

Properties

Name Type Description Notes Default Value
property icon ClientIDMode ClientIDMode Gets or sets the client ID generation algorithm.
attribute
inner element
static value
bindable
default
1
property icon DataContext Object Gets or sets a data context for the control and its children. All value and command bindings are evaluated in context of this value.
attribute
inner element
static value
bindable
default
null
property icon ID String Gets or sets the unique control ID.
attribute
inner element
static value
bindable
default
null
property icon IncludeErrorsFromChildren Boolean Gets or sets whether the errors from child objects in the viewmodel will be displayed too.
attribute
inner element
static value
bindable
default
False
property icon InnerText String Gets or sets the inner text of the HTML element.
attribute
inner element
static value
bindable
default
null
property icon Visible Boolean Gets or sets whether the control is visible.
attribute
inner element
static value
bindable
default
True

HTML produced by the control

This control renders the HTML unordered list.

<ul data-bind="foreach: ...">
  <li data-bind="..."></li>
</ul>