Back to Devexpress

ASPxGlobalEvents.ValidationCompleted Event

aspnet-devexpress-dot-web-dot-aspxglobalevents.md

latest4.7 KB
Original Source

ASPxGlobalEvents.ValidationCompleted Event

Occurs after the validation initiated for a DevExpress web control (or a group of DevExpress web controls) has been completed.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public event EventHandler<ValidationCompletedEventArgs> ValidationCompleted
vb
Public Event ValidationCompleted As EventHandler(Of ValidationCompletedEventArgs)

Event Data

The ValidationCompleted event's data class is ValidationCompletedEventArgs. The following properties provide information specific to this event:

PropertyDescription
ContainerGets a container object that holds the validated control(s).
FirstInvalidControlGets the first control (either visible or invisible) that hasn’t passed the validation applied.
FirstVisibleInvalidControlGets the first visible control that hasn’t passed the validation applied.
InvisibleControlsValidatedGets a value that indicates whether validation has been applied to both visible and invisible controls.
IsValidGets a value specifying whether the validation has been completed successfully.
ValidationGroupGets the name of the validation group to which validation has been applied.

Remarks

Each time validation initiated for a DevExpress web control or a group of DevExpress web controls is completed, the ValidationCompleted event is generated. This event fires after all ASPxEdit.Validation events of the validated DevExpress web controls.

A handler of the ValidationCompleted event is a suitable place to find out whether all DevExpress web controls have passed the validation (by analyzing the ValidationCompletedEventArgs.IsValid property). You can access the first control that failed the validation (by using the ValidationCompletedEventArgs.FirstInvalidControl or ValidationCompletedEventArgs.FirstVisibleInvalidControl property), obtain the container of the validated controls (ValidationCompletedEventArgs.Container) or the name of their validation group (ValidationCompletedEventArgs.ValidationGroup).

For instance, the ValidationCompleted event might be helpful if you validate editors located within different tab pages of the ASPxPageControl, and need to move input focus to an invalid editor within a non-active tab page.

Example

csharp
<script runat="server">
     protected void ASPxGlobalEvents1_ValidationCompleted(object sender, 
     DevExpress.Web.ValidationCompletedEventArgs e) {
     lErrorMessageNotEqual.ClientVisible = !tbPassword.Value.Equals(tbConfirmedPassword.Value);
     }
</script>
...
<dxge:ASPxGlobalEvents id="ASPxGlobalEvents1" runat="server" 
OnValidationCompleted="ASPxGlobalEvents1_ValidationCompleted">
    <ClientSideEvents ValidationCompleted="OnValidationCompleted" />
</dxge:ASPxGlobalEvents>
...
javascript
function OnValidationCompleted(s, e) {
                if(e.isValid && Password.GetValue() != ConfirmedPassword.GetValue()) {
                    ConfirmedPassword.SetFocus();
                    ErrorMessageNotEqual.SetVisible(true);
                    e.isValid = false;
                } else
                    ErrorMessageNotEqual.SetVisible(false);
            }

See Also

ASPxGlobalEvents Class

ASPxGlobalEvents Members

DevExpress.Web Namespace