DialogService Class

Class DialogService. Contains various methods with options to open and close dialogs. Should be added as scoped service in the application services and RadzenDialog should be added in application main layout.

Inheritance

Object

DialogService

Namespace: Radzen

Assembly: Radzen.Blazor.dll

Syntax

public class DialogService

Examples

@inject DialogService DialogService
<RadzenButton Text="Show dialog with inline Blazor content" Click=@ShowInlineDialog />
@code {
 async Task ShowInlineDialog()
 {
   var result = await DialogService.OpenAsync("Simple Dialog", ds =>
     @<div>
         <p Style="margin-bottom: 1rem">Confirm?</p>
         <div class="row">
             <div class="col-md-12">
                 <RadzenButton Text="Ok" Click="() => ds.Close(true)" Style="margin-bottom: 10px; width: 150px" />
                 <RadzenButton Text="Cancel" Click="() => ds.Close(false)" ButtonStyle="ButtonStyle.Base"  Style="margin-bottom: 10px; width: 150px"/>
                 <RadzenButton Text="Refresh" Click="(() => { orderID = 10249; ds.Refresh(); })" ButtonStyle="ButtonStyle.Info"  Style="margin-bottom: 10px; width: 150px"/>
                 Order ID: @orderID
             </div>
         </div>
     </div>);
   Console.WriteLine($"Dialog result: {result}");
 }
}

Constructors

DialogServicelink

Initializes a new instance of the DialogService class.

Declaration
public DialogService(NavigationManager uriHelper, Microsoft.JSInterop.IJSRuntime jsRuntime)
Parameters
Type Name Description
NavigationManager uriHelper The URI helper.
Microsoft.JSInterop.IJSRuntime jsRuntime IJSRuntime instance.

Fields

dialogslink

The dialogs

Declaration
protected List<object> dialogs

taskslink

The tasks

Declaration
protected List<TaskCompletionSource<object>> tasks

Methods

Alertlink

Displays a alert dialog.

Declaration
public virtual Task<bool?> Alert(string message, string title, AlertOptions options, Threading.CancellationToken? cancellationToken)
Parameters
Type Name Description
string message The message displayed to the user.
string title The text displayed in the title bar of the dialog.
AlertOptions options The options.
Threading.CancellationToken? cancellationToken The cancellation token.
Returns
Type Description
Task<bool?>true if the user clicked the OK button, false otherwise.

Alertlink

Displays a alert dialog.

Declaration
public virtual Task<bool?> Alert(RenderFragment message, string title, AlertOptions options, Threading.CancellationToken? cancellationToken)
Parameters
Type Name Description
RenderFragment message The message displayed to the user.
string title The text displayed in the title bar of the dialog.
AlertOptions options The options.
Threading.CancellationToken? cancellationToken The cancellation token.
Returns
Type Description
Task<bool?>true if the user clicked the OK button, false otherwise.

Closelink

Closes the side dialog

Declaration
public virtual void Close(object result)
Parameters
Type Name Description
object result The result of the Dialog

CloseSidelink

Closes the side dialog

Declaration
public virtual void CloseSide(object result)
Parameters
Type Name Description
object result The result of the Dialog

CloseSideAsynclink

Closes the side dialog and waits for the closing animation to finish.

Declaration
public Task CloseSideAsync(object result)
Parameters
Type Name Description
object result The result of the Dialog
Returns
Type Description
Task

Confirmlink

Displays a confirmation dialog.

Declaration
public virtual Task<bool?> Confirm(string message, string title, ConfirmOptions options, Threading.CancellationToken? cancellationToken)
Parameters
Type Name Description
string message The message displayed to the user.
string title The text displayed in the title bar of the dialog.
ConfirmOptions options The options.
Threading.CancellationToken? cancellationToken The cancellation token.
Returns
Type Description
Task<bool?>true if the user clicked the OK button, false otherwise.

Confirmlink

Displays a confirmation dialog.

Declaration
public virtual Task<bool?> Confirm(RenderFragment message, string title, ConfirmOptions options, Threading.CancellationToken? cancellationToken)
Parameters
Type Name Description
RenderFragment message The message displayed to the user.
string title The text displayed in the title bar of the dialog.
ConfirmOptions options The options.
Threading.CancellationToken? cancellationToken The cancellation token.
Returns
Type Description
Task<bool?>true if the user clicked the OK button, false otherwise.

Disposelink

Declaration
public void Dispose()

Openlink

Opens a dialog with the specified arguments.

Declaration
public virtual void Open(string title, Dictionary<string, object> parameters, DialogOptions options)
Parameters
Type Name Description
string title The text displayed in the title bar of the dialog.
Dictionary<string, object> parameters The dialog parameters.
DialogOptions options The dialog options.

Openlink

Opens a dialog with the specified arguments.

Declaration
public virtual void Open(string title, Type componentType, Dictionary<string, object> parameters, DialogOptions options)
Parameters
Type Name Description
string title The text displayed in the title bar of the dialog.
Type componentType
Dictionary<string, object> parameters The dialog parameters.
DialogOptions options The dialog options.

Openlink

Opens a dialog with the specified arguments.

Declaration
public virtual void Open(string title, RenderFragment<DialogService> childContent, DialogOptions options)
Parameters
Type Name Description
string title The text displayed in the title bar of the dialog.
RenderFragment<DialogService> childContent
DialogOptions options The dialog options.

OpenAsynclink

Opens a dialog with the specified arguments.

Declaration
public virtual Task<object> OpenAsync(string title, Dictionary<string, object> parameters, DialogOptions options)
Parameters
Type Name Description
string title The text displayed in the title bar of the dialog.
Dictionary<string, object> parameters The dialog parameters. Passed as property values of T.
DialogOptions options The dialog options.
Returns
Type Description
Task<object>The value passed as argument to Object).

OpenAsynclink

Opens a dialog with the specified arguments.

Declaration
public virtual Task<object> OpenAsync(string title, Type componentType, Dictionary<string, object> parameters, DialogOptions options)
Parameters
Type Name Description
string title The text displayed in the title bar of the dialog.
Type componentType
Dictionary<string, object> parameters The dialog parameters. Passed as property values of T.
DialogOptions options The dialog options.
Returns
Type Description
Task<object>The value passed as argument to Object).

OpenAsynclink

Opens a dialog with the specified arguments.

Declaration
public virtual Task<object> OpenAsync(string title, RenderFragment<DialogService> childContent, DialogOptions options, Threading.CancellationToken? cancellationToken)
Parameters
Type Name Description
string title The text displayed in the title bar of the dialog.
RenderFragment<DialogService> childContent
DialogOptions options The dialog options.
Threading.CancellationToken? cancellationToken
Returns
Type Description
Task<object>The value passed as argument to Object).

OpenAsynclink

Opens a dialog with the specified arguments.

Declaration
public virtual Task<object> OpenAsync(RenderFragment<DialogService> titleContent, RenderFragment<DialogService> childContent, DialogOptions options, Threading.CancellationToken? cancellationToken)
Parameters
Type Name Description
RenderFragment<DialogService> titleContent
RenderFragment<DialogService> childContent
DialogOptions options The dialog options.
Threading.CancellationToken? cancellationToken
Returns
Type Description
Task<object>The value passed as argument to Object).

OpenSidelink

Opens a side dialog with the specified arguments

Declaration
public void OpenSide(string title, Dictionary<string, object> parameters, SideDialogOptions options)
Parameters
Type Name Description
string title The text displayed in the title bar of the side dialog.
Dictionary<string, object> parameters The dialog parameters. Passed as property values of T
SideDialogOptions options The side dialog options.

OpenSidelink

Opens a side dialog with the specified arguments

Declaration
public void OpenSide(string title, Type componentType, Dictionary<string, object> parameters, SideDialogOptions options)
Parameters
Type Name Description
string title The text displayed in the title bar of the side dialog.
Type componentType
Dictionary<string, object> parameters The dialog parameters. Passed as property values of T
SideDialogOptions options The side dialog options.

OpenSideAsynclink

Opens a side dialog with the specified arguments

Declaration
public Task<object> OpenSideAsync(string title, Dictionary<string, object> parameters, SideDialogOptions options)
Parameters
Type Name Description
string title The text displayed in the title bar of the side dialog.
Dictionary<string, object> parameters The dialog parameters. Passed as property values of T
SideDialogOptions options The side dialog options.
Returns
Type Description
Task<object>A task that completes when the dialog is closed or a new one opened

OpenSideAsynclink

Opens a side dialog with the specified arguments

Declaration
public Task<object> OpenSideAsync(string title, Type componentType, Dictionary<string, object> parameters, SideDialogOptions options)
Parameters
Type Name Description
string title The text displayed in the title bar of the side dialog.
Type componentType
Dictionary<string, object> parameters The dialog parameters. Passed as property values of T
SideDialogOptions options The side dialog options.
Returns
Type Description
Task<object>A task that completes when the dialog is closed or a new one opened

Refreshlink

Invokes OnRefresh.

Declaration
public void Refresh()

Events

OnCloselink

Raises the Close event.

Declaration
public event Action<object> OnClose

OnOpenlink

Occurs when a new dialog is open.

Declaration
public event Action<string, Type, Dictionary<string, object>, DialogOptions> OnOpen

OnRefreshlink

Occurs when [on refresh].

Declaration
public event Action OnRefresh

OnSideCloselink

Raises the Close event for the side dialog

Declaration
public event Action<object> OnSideClose

OnSideOpenlink

Raises the Open event for the side dialog

Declaration
public event Action<Type, Dictionary<string, object>, SideDialogOptions> OnSideOpen
An error has occurred. This app may no longer respond until reloaded. Reload 🗙