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.Secondary"  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(String, String, AlertOptions)

    Displays a alert dialog.

    Declaration
    public async Task<bool?> Alert(string message = "", string title = "Message", AlertOptions options = 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.

    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.

    Confirm(String, String, ConfirmOptions)

    Displays a confirmation dialog.

    Declaration
    public async Task<bool?> Confirm(string message = "Confirm?", string title = "Confirm", ConfirmOptions options = 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.

    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 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<T>(String, Dictionary<String, Object>, DialogOptions)

    Opens a dialog with the specified arguments.

    Declaration
    public 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. Passed as property values of T.

    DialogOptions options

    The dialog options.

    Type Parameters
    Name Description
    T

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

    OpenAsync(String, RenderFragment<DialogService>, DialogOptions)

    Opens a dialog with the specified content.

    Declaration
    public Task<dynamic> OpenAsync(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.

    Returns
    Type Description
    Task<System.Object>

    The value passed as argument to Close(Object).

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

    Opens a dialog with the specified arguments.

    Declaration
    public 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.

    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

    Boost your Blazor development with Radzen

    Radzen is a desktop tool that gives you the power to create line of business applications. Build and launch Blazor apps visually, while we generate clean code for you.

    Learn More

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