Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

IToastNotificationService Interface

In This Article

Allows you to manage toast notifications in code.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public interface IToastNotificationService

#Remarks

The toast notification service allows you to create, show, and close toast notifications in code. To use the service, inject it with the [Inject] attribute.

C#
[Inject] IToastNotificationService ToastService { get; set; }

Use methods implemented by the interface to manage toast notifications in code.

  • The ShowToast method overloads allow you to create and show toast notifications at runtime or to show DxToast components declared in markup.

    razor
    <DxButton Text="Create a toast" Click="CreateToastAtRuntime" />
    <DxButton Text="Show a declared toast" Click="ShowDeclaredToast" />
    <DxToastProvider />
    
    <DxToast Id="toast1" Text="The toast specified in markup." />
    
    @code {
        [Inject] IToastNotificationService ToastService { get; set; }
    
        private void CreateToastAtRuntime() {
            ToastService.ShowToast(new ToastOptions {
                Id = "toast2",
                Title = "New toast",
                Text = "The new toast is created.",
            });
        }
        private void ShowDeclaredToast() {
            ToastService.ShowToast("toast1");
        }
    }
    
  • The CloseToast(String) method allows you to close toast notifications.

    razor
    ToastService.CloseToast("toast1");
    ToastService.CloseToast("toast2");
    

Run Demo: Overview Watch Video: Getting Started

See Also