The IDialogService provides methods for displaying modal dialogs to the user, including confirmation prompts, error messages, informational notices, success notifications, and warnings.
Access the dialog service from any component. In React call useDialogService() from inside the tree wrapped by the framework dialog provider; in Blazor inject the service via property injection. Note that the PowerPortalsPro dialog service is distinct from the underlying FluentUI dialog service.
// useDialogService() returns the framework's dialog API. Available from any
// function component below the <FluentDialogProvider> mounted at the app
// root. The returned object exposes async show* methods for confirmations,
// info / success / warning / error message bars, and custom dialog rendering.
import { useDialogService } from '@powerportalspro/react-fluent';
function MyComponent() {
const dialogs = useDialogService();
// ...
}using IDialogService = PowerPortalsPro.Web.Blazor.Services.IDialogService;
[Inject]
private IDialogService _dialogService { get; set; } = null!;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.
const result = await dialogs.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
}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
}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 dialogs.showInfoAsync('The operation completed.', 'Information');
await dialogs.showSuccessAsync('Record saved successfully.', 'Success');
await dialogs.showWarningAsync('This action cannot be undone.', 'Warning');
await dialogs.showErrorAsync('An error occurred while saving.', 'Error');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");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.
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.
Use the controls below to customize the dialog title and message, then click any button to see the corresponding dialog type.
Name | Parameters | Type | Description |
|---|---|---|---|
ShowConfirmationAsync | string 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 |
ShowErrorAsync | string message string title string primaryText | Task<DialogResult> | Shows an error dialog with the supplied message and waits for the user to dismiss it. |
ShowInfoAsync | string message string title string primaryText | Task<DialogResult> | Shows an informational dialog with the supplied message and waits for the user to dismiss it. |
ShowSuccessAsync | string message string title string primaryText | Task<DialogResult> | Shows a success dialog with the supplied message and waits for the user to dismiss it. |
ShowWarningAsync | string message string title string primaryText | Task<DialogResult> | Shows a warning dialog with the supplied message and waits for the user to dismiss it. |
ShowConfirmationAsyncmessage and two action buttons, then waits for the user to choose one. The returned Services.DialogResult has DialogResult.Cancelled set to ShowErrorAsyncmessage and waits for the user to dismiss it.ShowInfoAsyncmessage and waits for the user to dismiss it.ShowSuccessAsyncmessage and waits for the user to dismiss it.ShowWarningAsyncmessage and waits for the user to dismiss it.Name | Type | Default | Description |
|---|---|---|---|
Cancelled | bool | False | Gets a value indicating whether the dialog was cancelled (e.g. the user dismissed it without confirming). |
Data | Object? | Optional data payload returned by the dialog when it was closed. |
CancelledDataName | Parameters | Type | Description |
|---|---|---|---|
Cancel | Object 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. |
CancelServices.DialogResult representing a cancelled outcome, optionally carrying a data payload.Ok<T>Services.DialogResult representing a confirmed outcome, carrying result as the data payload.