Demos About Radzen
Search Results for

    Show / Hide Table of Contents

    Class DialogService

    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
    System.Object
    DialogService
    Namespace: Radzen
    Assembly: Radzen.Blazor.dll
    Syntax
    public class DialogService : IDisposable
    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

    DialogService(NavigationManager, IJSRuntime)

    Initializes a new instance of the DialogService class.

    Declaration
    public DialogService(NavigationManager uriHelper, IJSRuntime jsRuntime)
    Parameters
    Type Name Description
    NavigationManager uriHelper

    The URI helper.

    IJSRuntime jsRuntime

    IJSRuntime instance.

    Fields

    dialogs

    The dialogs

    Declaration
    protected List<object> dialogs
    Field Value
    Type Description
    List<System.Object>

    tasks

    The tasks

    Declaration
    protected List<TaskCompletionSource<dynamic>> tasks
    Field Value
    Type Description
    List<TaskCompletionSource<System.Object>>

    Methods

    Alert(RenderFragment, String, AlertOptions, Nullable<CancellationToken>)

    Displays a alert dialog.

    Declaration
    public virtual async Task<bool?> Alert(RenderFragment message, string title = "Message", AlertOptions options = null, CancellationToken? cancellationToken = null)
    Parameters
    Type Name Description
    RenderFragment message

    The message displayed to the user.

    System.String title

    The text displayed in the title bar of the dialog.

    AlertOptions options

    The options.

    System.Nullable<CancellationToken> cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<System.Nullable<System.Boolean>>

    true if the user clicked the OK button, false otherwise.

    Alert(String, String, AlertOptions, Nullable<CancellationToken>)

    Displays a alert dialog.

    Declaration
    public virtual async Task<bool?> Alert(string message = "", string title = "Message", AlertOptions options = null, CancellationToken? cancellationToken = null)
    Parameters
    Type Name Description
    System.String message

    The message displayed to the user.

    System.String title

    The text displayed in the title bar of the dialog.

    AlertOptions options

    The options.

    System.Nullable<CancellationToken> cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<System.Nullable<System.Boolean>>

    true if the user clicked the OK button, false otherwise.

    Close(Object)

    Closes the last opened dialog with optional result.

    Declaration
    public virtual void Close(dynamic result = null)
    Parameters
    Type Name Description
    System.Object result

    The result.

    CloseSide(Object)

    Closes the side dialog

    Declaration
    public void CloseSide(dynamic result = null)
    Parameters
    Type Name Description
    System.Object result

    The result of the Dialog

    Confirm(RenderFragment, String, ConfirmOptions, Nullable<CancellationToken>)

    Displays a confirmation dialog.

    Declaration
    public virtual async Task<bool?> Confirm(RenderFragment message, string title = "Confirm", ConfirmOptions options = null, CancellationToken? cancellationToken = null)
    Parameters
    Type Name Description
    RenderFragment message

    The message displayed to the user.

    System.String title

    The text displayed in the title bar of the dialog.

    ConfirmOptions options

    The options.

    System.Nullable<CancellationToken> cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<System.Nullable<System.Boolean>>

    true if the user clicked the OK button, false otherwise.

    Confirm(String, String, ConfirmOptions, Nullable<CancellationToken>)

    Displays a confirmation dialog.

    Declaration
    public virtual async Task<bool?> Confirm(string message = "Confirm?", string title = "Confirm", ConfirmOptions options = null, CancellationToken? cancellationToken = null)
    Parameters
    Type Name Description
    System.String message

    The message displayed to the user.

    System.String title

    The text displayed in the title bar of the dialog.

    ConfirmOptions options

    The options.

    System.Nullable<CancellationToken> cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<System.Nullable<System.Boolean>>

    true if the user clicked the OK button, false otherwise.

    Dispose()

    Declaration
    public void Dispose()

    Open(String, RenderFragment<DialogService>, DialogOptions)

    Opens a dialog with the specified content.

    Declaration
    public virtual void Open(string title, RenderFragment<DialogService> childContent, DialogOptions options = null)
    Parameters
    Type Name Description
    System.String title

    The text displayed in the title bar of the dialog.

    RenderFragment<DialogService> childContent

    The content displayed in the dialog.

    DialogOptions options

    The dialog options.

    Open(String, Type, Dictionary<String, Object>, DialogOptions)

    Opens a dialog with the specified arguments.

    Declaration
    public virtual void Open(string title, Type componentType, Dictionary<string, object> parameters = null, DialogOptions options = null)
    Parameters
    Type Name Description
    System.String title

    The text displayed in the title bar of the dialog.

    Type componentType

    The type of the component to be displayed in the dialog. Must inherit from .

    Dictionary<System.String, System.Object> parameters

    The dialog parameters.

    DialogOptions options

    The dialog options.

    Open<T>(String, Dictionary<String, Object>, DialogOptions)

    Opens a dialog with the specified arguments.

    Declaration
    public virtual void Open<T>(string title, Dictionary<string, object> parameters = null, DialogOptions options = null)
        where T : ComponentBase
    Parameters
    Type Name Description
    System.String title

    The text displayed in the title bar of the dialog.

    Dictionary<System.String, System.Object> parameters

    The dialog parameters.

    DialogOptions options

    The dialog options.

    Type Parameters
    Name Description
    T

    The type of the Blazor component which will be displayed in a dialog.

    OpenAsync(RenderFragment<DialogService>, RenderFragment<DialogService>, DialogOptions, Nullable<CancellationToken>)

    Opens a dialog with the specified content.

    Declaration
    public virtual Task<dynamic> OpenAsync(RenderFragment<DialogService> titleContent, RenderFragment<DialogService> childContent, DialogOptions options = null, CancellationToken? cancellationToken = null)
    Parameters
    Type Name Description
    RenderFragment<DialogService> titleContent

    The content displayed in the title bar of the dialog.

    RenderFragment<DialogService> childContent

    The content displayed in the dialog.

    DialogOptions options

    The dialog options.

    System.Nullable<CancellationToken> cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<System.Object>

    The value passed as argument to Close(Object).

    OpenAsync(String, RenderFragment<DialogService>, DialogOptions, Nullable<CancellationToken>)

    Opens a dialog with the specified content.

    Declaration
    public virtual Task<dynamic> OpenAsync(string title, RenderFragment<DialogService> childContent, DialogOptions options = null, CancellationToken? cancellationToken = null)
    Parameters
    Type Name Description
    System.String title

    The text displayed in the title bar of the dialog.

    RenderFragment<DialogService> childContent

    The content displayed in the dialog.

    DialogOptions options

    The dialog options.

    System.Nullable<CancellationToken> cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<System.Object>

    The value passed as argument to Close(Object).

    OpenAsync(String, Type, Dictionary<String, Object>, DialogOptions)

    Opens a dialog with the specified arguments dynamically.

    Declaration
    public virtual Task<dynamic> OpenAsync(string title, Type componentType, Dictionary<string, object> parameters = null, DialogOptions options = null)
    Parameters
    Type Name Description
    System.String title

    The text displayed in the title bar of the dialog.

    Type componentType

    The type of the Blazor component to be displayed in a dialog. Must inherit from .

    Dictionary<System.String, System.Object> parameters

    The dialog parameters, passed as property values of the specified component.

    DialogOptions options

    The dialog options.

    Returns
    Type Description
    Task<System.Object>

    A task that represents the result passed as an argument to Close(Object).

    OpenAsync<T>(String, Dictionary<String, Object>, DialogOptions)

    Opens a dialog with the specified arguments.

    Declaration
    public virtual Task<dynamic> OpenAsync<T>(string title, Dictionary<string, object> parameters = null, DialogOptions options = null)
        where T : ComponentBase
    Parameters
    Type Name Description
    System.String title

    The text displayed in the title bar of the dialog.

    Dictionary<System.String, System.Object> parameters

    The dialog parameters. Passed as property values of T.

    DialogOptions options

    The dialog options.

    Returns
    Type Description
    Task<System.Object>

    The value passed as argument to Close(Object).

    Type Parameters
    Name Description
    T

    The type of the Blazor component which will be displayed in a dialog.

    OpenSide(String, Type, Dictionary<String, Object>, SideDialogOptions)

    Opens a side dialog with the specified arguments dynamically.

    Declaration
    public void OpenSide(string title, Type componentType, Dictionary<string, object> parameters = null, SideDialogOptions options = null)
    Parameters
    Type Name Description
    System.String title

    The text displayed in the title bar of the side dialog.

    Type componentType

    The type of the Blazor component to be displayed in the side dialog. Must inherit from .

    Dictionary<System.String, System.Object> parameters

    The dialog parameters, passed as property values of the specified component.

    SideDialogOptions options

    The side dialog options.

    OpenSide<T>(String, Dictionary<String, Object>, SideDialogOptions)

    Opens a side dialog with the specified arguments

    Declaration
    public void OpenSide<T>(string title, Dictionary<string, object> parameters = null, SideDialogOptions options = null)
        where T : ComponentBase
    Parameters
    Type Name Description
    System.String title

    The text displayed in the title bar of the side dialog.

    Dictionary<System.String, System.Object> parameters

    The dialog parameters. Passed as property values of T

    SideDialogOptions options

    The side dialog options.

    Type Parameters
    Name Description
    T

    The type of Blazor component which will be displayed in the side dialog.

    OpenSideAsync(String, Type, Dictionary<String, Object>, SideDialogOptions)

    Opens a side dialog with the specified arguments dynamically.

    Declaration
    public Task<dynamic> OpenSideAsync(string title, Type componentType, Dictionary<string, object> parameters = null, SideDialogOptions options = null)
    Parameters
    Type Name Description
    System.String title

    The text displayed in the title bar of the side dialog.

    Type componentType

    The type of the Blazor component to be displayed in the side dialog. Must inherit from .

    Dictionary<System.String, System.Object> parameters

    The dialog parameters, passed as property values of the specified component.

    SideDialogOptions options

    The side dialog options.

    Returns
    Type Description
    Task<System.Object>

    A task that represents the result passed as an argument to CloseSide(Object).

    OpenSideAsync<T>(String, Dictionary<String, Object>, SideDialogOptions)

    Opens a side dialog with the specified arguments

    Declaration
    public Task<dynamic> OpenSideAsync<T>(string title, Dictionary<string, object> parameters = null, SideDialogOptions options = null)
        where T : ComponentBase
    Parameters
    Type Name Description
    System.String title

    The text displayed in the title bar of the side dialog.

    Dictionary<System.String, System.Object> parameters

    The dialog parameters. Passed as property values of T

    SideDialogOptions options

    The side dialog options.

    Returns
    Type Description
    Task<System.Object>

    A task that completes when the dialog is closed or a new one opened

    Type Parameters
    Name Description
    T

    The type of Blazor component which will be displayed in the side dialog.

    Refresh()

    Invokes OnRefresh.

    Declaration
    public void Refresh()

    Events

    OnClose

    Raises the Close event.

    Declaration
    public event Action<dynamic> OnClose
    Event Type
    Type Description
    Action<System.Object>

    OnOpen

    Occurs when a new dialog is open.

    Declaration
    public event Action<string, Type, Dictionary<string, object>, DialogOptions> OnOpen
    Event Type
    Type Description
    Action<System.String, Type, Dictionary<System.String, System.Object>, DialogOptions>

    OnRefresh

    Occurs when [on refresh].

    Declaration
    public event Action OnRefresh
    Event Type
    Type Description
    Action

    OnSideClose

    Raises the Close event for the side dialog

    Declaration
    public event Action<dynamic> OnSideClose
    Event Type
    Type Description
    Action<System.Object>

    OnSideOpen

    Raises the Open event for the side dialog

    Declaration
    public event Action<Type, Dictionary<string, object>, SideDialogOptions> OnSideOpen
    Event Type
    Type Description
    Action<Type, Dictionary<System.String, System.Object>, SideDialogOptions>

    Introducing Radzen Blazor Studio

    Radzen Blazor Studio is a software development environment that empowers developers to design, build and deploy Blazor applications without the traditional hurdles. Write less code and get more done.

    Learn More

    Download Now
    Download Now
    In This Article
    Back to top Radzen Blazor Components, © 2018-2025 Radzen. Source Code licensed under MIT