[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
   Getting Started
  [Expand]Grid View
  [Collapse]Tree List
   [Expand]Product Information
    [Expand]Binding to Data
    [Expand]Data Representation Basics
    [Collapse]Data Editing
      Edit Form
      Batch Edit Mode
      Adding and Deleting Nodes
      Node Validation and Error Indication
    [Expand]Data Shaping and Manipulation
     Drag and Drop
    [Expand]Focus and Navigation
     Appearance Customization
     Save and Restore Client Layout
   [Expand]Visual Elements
   [Expand]Member Tables
  [Expand]Card View
  [Expand]Chart Control
  [Expand]Pivot Grid
  [Expand]Rich Text Editor
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Vertical Grid
  [Expand]Data Editors
  [Expand]Docking and Popups
  [Expand]File Management
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Controls
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Node Validation and Error Indication

Expanded Validating Edit Cells (Client-Side Validation)

Data columns provide various validation settings available via the ASPxEdit.ValidationSettings property. This allows you to define the validation logic for individual edit cells.

In this instance, if the validation fails, error icons are displayed next to the editors with invalid values. The node will not be updated while it contains invalid values.

However, if you wish to design the Edit Form yourself, you should add editors to the Edit Form's Template Container or a column's Edit Item Template Container. In this instance, client-side validation will not work.

The ASPxTreeListTemplateReplacement control doesn't know about custom editors used in a template container. The result of the client-side validation is ignored when pressing the standard Update button. As a result, the update edit callback is sent to the server.

In this situation, you should implement server-side validation by handling the ASPxTreeList.NodeValidating event. Otherwise, invalid data will be posted to a database.

To avoid this behavior, and enable client-side validation, the standard Update button should be replaced with a custom button. Its client-side Click event must be handled to validate data. If the entered data is valid, you should call the tree list's client-side ASPxClientTreeList.UpdateEdit method. In this situation, the update edit callback will not be sent to the server while the Edit Form contains invalid values.

Expanded Example: Edit Form Template Container Validation

This example shows how to validate custom editors, contained within the Edit Form Template Container, on the client. In this sample, we use the ASPxClientEdit.ValidateGroup method to perform client-side validation of editors that belong to the "EditForm" validation group.

Expanded Validating Nodes (Server-Side Validation)

To implement node validation, you should handle the ASPxTreeList.NodeValidating event. This event is automatically raised when a node is about to be updated, and allows you to specify whether its data is valid. To manually force node validation, call the ASPxTreeList.DoNodeValidation method.

  • The event's OldValues and NewValues properties allow the old and new node values to be obtained, respectively. These properties represent collections. Individual node values can be obtained via index notation, or by specifying the field name. The event's IsNewNode property identifies whether a new node is being edited by the user.
  • If the value is invalid, use the Errors property to specify the error description text. As a result, an error icon will be displayed next to the invalid value. Pointing to the icon shows the hint with the error description.
  • Use the NodeError property to specify the error text displayed within the Error Node. This node is automatically displayed below the edited node, if the NodeError property is set to a string that is not empty.

Expanded Example

This example demonstrates how to check the validity of data entered by end-users into a node. Validation is implemented within the ASPxTreeList.NodeValidating event handler. In this sample, validation fails in the cases listed below:

  • the department isn't specified;
  • the budget is negative.

The image below shows the result:

Is this topic helpful?​​​​​​​