Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxMessageBox.Shown Event

In This Article

Fires after the message box is displayed.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
[Parameter]
public EventCallback Shown { get; set; }

#Remarks

Handle the Shown event to perform actions after the message box appears. The following code sample hides the message box 3 seconds after it is displayed:

razor
@using System.Timers;

<DxButton Text="Show Alert" Click="@(() => MessageBoxVisible = true)" />
<DxMessageBox @bind-Visible="MessageBoxVisible" 
              Title="Alert" 
              Text="I'm an alert that hides in 3 seconds" 
              Shown="@Shown" />

@code {
    bool MessageBoxVisible { get; set; } = false;
    static Timer mbTimer;

    void Shown() {
        mbTimer = new Timer(3000);
        mbTimer.Elapsed += OnTimedEvent;
        mbTimer.Enabled = true;
    }

    void OnTimedEvent(Object source, ElapsedEventArgs e) {
        MessageBoxVisible = false;
        mbTimer.Stop();
        mbTimer.Dispose();
        InvokeAsync(StateHasChanged);
    }
}
See Also