Back to Devexpress

IToastNotificationService.ShowToast(ToastOptions) Method

blazor-devexpress-dot-blazor-dot-itoastnotificationservice-dot-showtoast-x28-devexpress-dot-blazor-dot-toastoptions-x29.md

latest1.7 KB
Original Source

IToastNotificationService.ShowToast(ToastOptions) Method

Creates and shows a toast notification with the specified options.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
void ShowToast(
    ToastOptions toastOptions
)

Parameters

NameTypeDescription
toastOptionsToastOptions

An object that contains toast options.

|

Remarks

Call the ShowToast method to create and show a toast in code. This method overload accepts a ToastOptions object as a parameter. Use this parameter to set up toast settings.

Run Demo: Toast

razor
<DxButton Text="Show a toast" Click="AddToast" />
<DxButton Text="Hide a toast" Click="HideToast" />
<DxToastProvider DisplayTime="@TimeSpan.Zero" />
@code {
    [Inject] IToastNotificationService ToastService { get; set; }

    private void AddToast() {
        ToastService.ShowToast(new ToastOptions {
            Id = "TaskNotification",
            Title = "Notification",
            Text = "The process is completed.",
        });
    }
    private void HideToast() {
        ToastService.CloseToast("TaskNotification");
    }
}

See Also

IToastNotificationService Interface

IToastNotificationService Members

DevExpress.Blazor Namespace