Skip to main content

ASPxTreeList.DoNodeValidation() Method

Validates the node currently being edited.

Namespace: DevExpress.Web.ASPxTreeList

Assembly: DevExpress.Web.ASPxTreeList.v24.2.dll

Declaration

public void DoNodeValidation()

Remarks

The DoNodeValidation method raises the ASPxTreeList.NodeValidating event, so you can manually specify whether node values are valid.

Calling the DoNodeValidation method has no effect if the ASPxTreeList is in browse mode. To identify whether the ASPxTreeList is in edit mode, use the ASPxTreeList.IsEditing property.

To learn more, see Node Validation and Error Indication.

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:

NodeValidation

protected void ASPxTreeList1_NodeValidating(object sender, TreeListNodeValidationEventArgs e) {
    if ((int)e.NewValues["Budget"] < 0)
        e.Errors["Budget"] = "Negative values aren't allowed";
    if (e.NewValues["Department"] == null)
        e.Errors["Department"] = "Required field";
    if (e.Errors.Count != 0)
        e.NodeError = "Node update failed. Please check node values.";
}
See Also