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

IDialogService Interface

In This Article

Allows you to create and show dialogs in code.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public interface IDialogService

#Remarks

The dialog service allows you to create and show dialogs (DxMessageBox objects) in code. To use the service, inject it with the [Inject] attribute and declare a DxDialogProvider on the page.

razor
<DxDialogProvider />
@code {
    [Inject] IDialogService DialogService { get; set; }
}

Use methods implemented by the interface to create alert and confirmation dialogs.

AlertAsync(MessageBoxOptions)

Creates and shows an alert dialog that displays the OK button.

razor
<DxDialogProvider />
<DxButton Text="Show a message box window" Click="@OpenConfirmDialogAsync" />

@code {
    [Inject] IDialogService DialogService { get; set; }

    private async Task OpenConfirmDialogAsync() {
        await DialogService.AlertAsync(new MessageBoxOptions() {
            Title = "Error",
            Text = "Unable to process the request. Please try again later or contact support.",
            RenderStyle = MessageBoxRenderStyle.Danger
        });
    }
}

Message Box

ConfirmAsync(MessageBoxOptions)

Creates and shows a confirmation dialog that displays OK and Cancel buttons.

razor
<DxDialogProvider />
<DxButton Text="Show a message box window" Click="@OpenConfirmDialogAsync" />

@code {
    [Inject] IDialogService DialogService { get; set; }
    private bool? Result { get; set; } = null;

    private async Task OpenConfirmDialogAsync() {
        Result = await DialogService.ConfirmAsync(new MessageBoxOptions() {
            Title = "Error",
            Text = "Unable to process the request. Please try again later or contact support.",
            RenderStyle = MessageBoxRenderStyle.Danger,
            OkButtonText = "Contact Support",
            CancelButtonText = "Try Later",
        });
    }
}

Message Box

Run Demo: Message Box - Dialog Service

See Also