ClassDialogFactory
Provides programmatic access to display predefined dialog types - Alert, Confirm, and Prompt. Inject as a service or access through cascading parameter for showing modal dialogs without markup. These dialogs follow browser-native patterns with consistent styling and keyboard navigation. USAGE: Perfect for confirmation prompts, user notifications, and simple text input scenarios. STYLING: Dialogs automatically inherit the active Telerik theme styling.
Definition
Namespace:Telerik.Blazor
Assembly:Telerik.Blazor.dll
Syntax:
public class DialogFactory
Inheritance: objectDialogFactory
Methods
AlertAsync(string)
Opens an informational alert dialog with single OK button using the default page title. Displays a message that requires user acknowledgment before continuing. Use for notifications, warnings, or informational messages that don't require decisions. BEHAVIOR: Dialog blocks interaction with page content until user clicks OK or presses Escape. UX: Perfect for success messages, error notifications, or important announcements.
AlertAsync(string, string)
Opens an informational alert dialog with single OK button and custom title. Displays a message with descriptive title that requires user acknowledgment. Use when you need to categorize the alert or provide additional context through the title. CONTEXT: Title helps users understand the nature of the alert (Error, Warning, Success, etc.). BRANDING: Custom titles maintain consistency with your application's messaging patterns.
AlertAsync(string, string, string)
Opens an informational alert dialog with custom button text and title. Allows complete control over the acknowledgment button label. Use for localized applications or when "OK" doesn't match your application's vocabulary. LOCALIZATION: Essential for international applications requiring translated button text. UX: Custom button text can make the action more clear ("Got It", "Continue", "Close").
Declaration
public Task AlertAsync(string text, string title, string okButtonText)
Parameters
text
The informational message to display to the user.
title
The dialog title to display in the header bar.
okButtonText
Custom text for the acknowledgment button (replaces "OK").
Returns
Task that completes when user acknowledges the message.
ConfirmAsync(string)
Opens a confirmation dialog with yes/no options using the default page title. Displays the specified text with OK and Cancel buttons for user decision. Use for simple confirmation scenarios like "Are you sure you want to delete this item?". RETURN: true if user clicks OK/confirms, false if user clicks Cancel or closes dialog. ACCESSIBILITY: Dialog is modal and supports keyboard navigation (Enter=OK, Escape=Cancel).
ConfirmAsync(string, string)
Opens a confirmation dialog with yes/no options and custom title. Displays the specified text and title with OK and Cancel buttons for user decision. Use when you need to provide context through a descriptive title. RETURN: true if user clicks OK/confirms, false if user clicks Cancel or closes dialog. BRANDING: Custom title helps establish context and maintain consistent messaging.
Declaration
public Task<bool> ConfirmAsync(string text, string title)
Parameters
text
The message to display to the user asking for confirmation.
title
The dialog title to display in the header bar.
Returns
Task that resolves to true for confirmation, false for cancellation.
ConfirmAsync(string, string, string, string)
Opens a confirmation dialog with fully customized button text and title. Allows complete control over dialog appearance including button labels. Use for localized applications or when standard OK/Cancel text doesn't fit your context. RETURN: true if user clicks the OK button, false if user clicks Cancel button or closes dialog. LOCALIZATION: Essential for international applications requiring translated button text.
Declaration
public Task<bool> ConfirmAsync(string text, string title, string okButtonText, string cancelButtonText)
Parameters
text
The message to display to the user asking for confirmation.
title
The dialog title to display in the header bar.
okButtonText
Custom text for the confirmation button (replaces "OK").
cancelButtonText
Custom text for the cancellation button (replaces "Cancel").
Returns
Task that resolves to true for confirmation, false for cancellation.
PromptAsync(string)
Opens a text input dialog with OK/Cancel buttons using the default page title. Displays a message with a text input field for user to enter a single line of text. Use for collecting simple text input like names, descriptions, or configuration values. RETURN: User's text input if they click OK, null if they click Cancel or close dialog. UX: Input field is automatically focused when dialog opens for immediate typing.
PromptAsync(string, string)
Opens a text input dialog with OK/Cancel buttons and custom title. Displays a message and title with a text input field for user text entry. Use when you need to provide context for the input request through a descriptive title. RETURN: User's text input if they click OK, null if they click Cancel or close dialog. CONTEXT: Title helps explain what the input will be used for or provides additional context.
Declaration
public Task<string> PromptAsync(string text, string title)
Parameters
text
The prompt message asking the user for input.
title
The dialog title to display in the header bar.
Returns
Task that resolves to the user's input text or null if cancelled.
PromptAsync(string, string, string)
Opens a text input dialog with pre-filled default text and custom title. Displays a message with a text input field that contains initial text the user can modify. Use when you want to suggest a default value or allow editing of existing text. RETURN: User's final text input if they click OK, null if they click Cancel or close dialog. UX: Default text is pre-selected for easy replacement or can be modified as needed.
Declaration
public Task<string> PromptAsync(string text, string title, string defaultInputText)
Parameters
text
The prompt message asking the user for input.
title
The dialog title to display in the header bar.
defaultInputText
Pre-filled text that appears in the input field by default.
Returns
Task that resolves to the user's input text or null if cancelled.
PromptAsync(string, string, string, string, string)
Opens a fully customizable text input dialog with default text and custom button labels. Provides complete control over dialog appearance including button text and pre-filled input. Use for localized applications or when you need complete control over dialog messaging. RETURN: User's final text input if they click OK button, null if they click Cancel or close dialog. LOCALIZATION: Essential for international applications requiring translated button text. UX: Combines default text convenience with custom button labels for optimal user experience.
Declaration
public Task<string> PromptAsync(string text, string title, string defaultInputText, string okButtonText, string cancelButtonText)
Parameters
text
The prompt message asking the user for input.
title
The dialog title to display in the header bar.
defaultInputText
Pre-filled text that appears in the input field by default.
okButtonText
Custom text for the confirmation button (replaces "OK").
cancelButtonText
Custom text for the cancellation button (replaces "Cancel").
Returns
Task that resolves to the user's input text or null if cancelled.