IDialogService

The IDialogService provides methods for displaying modal dialogs to the user, including confirmation prompts, error messages, informational notices, success notifications, and warnings.

Injecting the Service

Inject IDialogService into any Blazor component via property injection. Note that this is the PowerPortalsPro dialog service (PowerPortalsPro.Web.Blazor.Services.IDialogService), not the FluentUI dialog service.

using IDialogService = PowerPortalsPro.Web.Blazor.Services.IDialogService;

[Inject]
private IDialogService _dialogService { get; set; } = null!;

Confirmation Dialogs

Use ShowConfirmationAsync to prompt the user with a yes/no question. The returned DialogResult.Cancelled property is true when the user selects the secondary (negative) option.

var result = await _dialogService.ShowConfirmationAsync(
    "Are you sure you want to delete this record?",
    title: "Confirm Delete",
    primaryText: "Yes",
    secondaryText: "No");

if (!result.Cancelled)
{
    // User confirmed — proceed with deletion
}

Message Dialogs

Use the following methods to show single-button message dialogs with different visual styles:

  • ShowInfoAsync — Informational message with a neutral icon.
  • ShowSuccessAsync — Success message with a green checkmark icon.
  • ShowWarningAsync — Warning message with a yellow warning icon.
  • ShowErrorAsync — Error message with a red error icon.
await _dialogService.ShowInfoAsync("The operation completed.", "Information");

await _dialogService.ShowSuccessAsync("Record saved successfully.", "Success");

await _dialogService.ShowWarningAsync("This action cannot be undone.", "Warning");

await _dialogService.ShowErrorAsync("An error occurred while saving.", "Error");

Common Parameters

All dialog methods accept optional title and primaryText parameters. If omitted, localized default values are used. The confirmation dialog also accepts a secondaryText parameter for the cancel button label.

Dialog Result

All methods return a DialogResult object. For confirmation dialogs, check the Cancelled property to determine the user's choice. For message dialogs, the result indicates the dialog was dismissed.

Interactive Demo

Use the controls below to customize the dialog title and message, then click any button to see the corresponding dialog type.

Blazor example
Show Confirmation Dialog Show Error Dialog Show Info Dialog Show Success Dialog Show Warning Dialog
React example
Blazor

IDialogService Interface

Methods

Name
Parameters
Type
Description
ShowConfirmationAsyncstring message
string title
string primaryText
string secondaryText
Task<DialogResult>
Shows a confirmation dialog with the supplied message and two action buttons, then waits for the user to choose one. The returned Services.DialogResult has DialogResult.Cancelled set to true when the user selects the secondary (negative) option.
ShowErrorAsyncstring message
string title
string primaryText
Task<DialogResult>
Shows an error dialog with the supplied message and waits for the user to dismiss it.
ShowInfoAsyncstring message
string title
string primaryText
Task<DialogResult>
Shows an informational dialog with the supplied message and waits for the user to dismiss it.
ShowSuccessAsyncstring message
string title
string primaryText
Task<DialogResult>
Shows a success dialog with the supplied message and waits for the user to dismiss it.
ShowWarningAsyncstring message
string title
string primaryText
Task<DialogResult>
Shows a warning dialog with the supplied message and waits for the user to dismiss it.
Name: ShowConfirmationAsync
Parameters: string message
string title
string primaryText
string secondaryText
Type: Task<DialogResult>
Description: Shows a confirmation dialog with the supplied message and two action buttons, then waits for the user to choose one. The returned Services.DialogResult has DialogResult.Cancelled set to true when the user selects the secondary (negative) option.
Name: ShowErrorAsync
Parameters: string message
string title
string primaryText
Type: Task<DialogResult>
Description: Shows an error dialog with the supplied message and waits for the user to dismiss it.
Name: ShowInfoAsync
Parameters: string message
string title
string primaryText
Type: Task<DialogResult>
Description: Shows an informational dialog with the supplied message and waits for the user to dismiss it.
Name: ShowSuccessAsync
Parameters: string message
string title
string primaryText
Type: Task<DialogResult>
Description: Shows a success dialog with the supplied message and waits for the user to dismiss it.
Name: ShowWarningAsync
Parameters: string message
string title
string primaryText
Type: Task<DialogResult>
Description: Shows a warning dialog with the supplied message and waits for the user to dismiss it.
React
Blazor

DialogResult Class

Properties

Name
Type
Default
Description
Cancelledbool
False
Gets a value indicating whether the dialog was cancelled (e.g. the user dismissed it without confirming).
DataObject?
Optional data payload returned by the dialog when it was closed.
Name: Cancelled
Type: bool
Default: False
Description: Gets a value indicating whether the dialog was cancelled (e.g. the user dismissed it without confirming).
Name: Data
Type: Object?
Description: Optional data payload returned by the dialog when it was closed.

Methods

Name
Parameters
Type
Description
CancelObject data
DialogResult
Creates a Services.DialogResult representing a cancelled outcome, optionally carrying a data payload.
Ok<T>T result
DialogResult
Creates a Services.DialogResult representing a confirmed outcome, carrying result as the data payload.
Name: Cancel
Parameters: Object data
Type: DialogResult
Description: Creates a Services.DialogResult representing a cancelled outcome, optionally carrying a data payload.
Name: Ok<T>
Parameters: T result
Type: DialogResult
Description: Creates a Services.DialogResult representing a confirmed outcome, carrying result as the data payload.
React