Back to Devexpress

IDialogService.ConfirmAsync(MessageBoxOptions) Method

blazor-devexpress-dot-blazor-dot-idialogservice-dot-confirmasync-x28-devexpress-dot-blazor-dot-messageboxoptions-x29.md

latest2.3 KB
Original Source

IDialogService.ConfirmAsync(MessageBoxOptions) Method

Shows a confirmation dialog (message box).

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
Task<bool> ConfirmAsync(
    MessageBoxOptions messageBoxOptions
)

Parameters

NameTypeDescription
messageBoxOptionsMessageBoxOptions

An object that contains message box options.

|

Returns

TypeDescription
Task<Boolean>

The task that is completed when the dialog is closed.
The task returns true if a user clicks the OK button.
The task returns false if a user clicks the Cancel button or closes the dialog in another way: clicks the Close button, presses Escape, or clicks outside the box boundaries.

|

Remarks

Call the ConfirmAsync method to show a message box of the Confirmation type in code. Use the method parameter to set up the message box settings.

Run Demo: Message Box - Dialog Service

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",
        });
    }
}

See Also

IDialogService Interface

IDialogService Members

DevExpress.Blazor Namespace