menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class ToastEvents - Blazor API Reference | Syncfusion

    Show / Hide Table of Contents

    Class ToastEvents

    Configure the event handlers to handle the events with SfToast component.

    Inheritance
    System.Object
    ToastEvents
    Namespace: Syncfusion.Blazor.Notifications
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class ToastEvents : OwningComponentBase
    Remarks

    The ToastEvents class provides a structured way to define event handlers for various toast-related events. This class inherits from Microsoft.AspNetCore.Components.OwningComponentBase and automatically registers itself with the parent SfToast component. All events are optional and will only be triggered if handlers are provided.

    Examples

    A simple ToastEvents configuration.

    <SfToast>
        <ToastEvents OnOpen="@OnToastOpen" 
                     OnClose="@OnToastClose" 
                     OnClick="@OnToastClick" 
                     Opened="@OnToastOpened" 
                     Closed="@OnToastClosed" 
                     Created="@OnToastCreated" 
                     Destroyed="@OnToastDestroyed" />
    </SfToast>
    
    @code {
        private void OnToastOpen(ToastBeforeOpenArgs args) 
        {
            // Handle before toast opens
        }
    
        private void OnToastClick(ToastClickEventArgs args) 
        {
            // Handle toast click
        }
    }

    Constructors

    ToastEvents()

    Declaration
    public ToastEvents()

    Properties

    Closed

    Gets or sets an event callback that is raised after the toast has been hidden.

    Declaration
    public EventCallback<ToastCloseArgs> Closed { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<ToastCloseArgs>

    An Microsoft.AspNetCore.Components.EventCallback<> that is invoked after the toast disappears. The callback receives a ToastCloseArgs argument.

    Remarks

    This event is triggered after the toast notification has been completely hidden or removed from the display. You can use this event to perform post-hiding operations, update application state, or trigger follow-up actions after the toast has been dismissed. The event provides information about the closed toast and the reason for closure.

    Created

    Gets or sets an event callback that is raised after the toast component has been created.

    Declaration
    public EventCallback<object> Created { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<System.Object>

    An Microsoft.AspNetCore.Components.EventCallback<> that is invoked after the toast is initialized. The callback receives an System.Object argument.

    Remarks

    This event is triggered after the toast component has been successfully created and initialized in memory. You can use this event to perform initialization operations, set up additional configurations, or register the toast with other components. The event is fired once per toast instance during its lifecycle.

    Destroyed

    Gets or sets an event callback that is raised after the toast component has been destroyed.

    Declaration
    public EventCallback<object> Destroyed { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<System.Object>

    An Microsoft.AspNetCore.Components.EventCallback<> that is invoked after the toast is disposed. The callback receives an System.Object argument.

    Remarks

    This event is triggered after the toast component has been completely destroyed and removed from memory. You can use this event to perform cleanup operations, release resources, or notify other components about the toast's destruction. The event is fired once per toast instance when it is being disposed.

    OnClick

    Gets or sets an event callback that is raised when the toast is clicked.

    Declaration
    public EventCallback<ToastClickEventArgs> OnClick { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<ToastClickEventArgs>

    An Microsoft.AspNetCore.Components.EventCallback<> that is invoked when the user clicks on the toast. The callback receives a ToastClickEventArgs argument.

    Remarks

    This event is triggered whenever the user clicks anywhere on the toast notification area. You can use this event to handle user interactions with the toast, such as navigating to related content, performing actions, or dismissing the toast manually. The event provides information about the clicked toast and the click event details.

    OnClose

    Gets or sets an event callback that is raised before the toast is closed.

    Declaration
    public EventCallback<ToastBeforeCloseArgs> OnClose { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<ToastBeforeCloseArgs>

    An Microsoft.AspNetCore.Components.EventCallback<> that is invoked before the toast disappears. The callback receives a ToastBeforeCloseArgs argument.

    Remarks

    This event is triggered just before the toast notification is hidden or removed from the display. You can use this event to perform cleanup operations, save state information, or cancel the close operation by setting the Cancel property of the event arguments. The event provides access to the closing toast's information and allows for intervention in the closing process.

    OnOpen

    Gets or sets an event callback that is raised before the toast is shown.

    Declaration
    public EventCallback<ToastBeforeOpenArgs> OnOpen { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<ToastBeforeOpenArgs>

    An Microsoft.AspNetCore.Components.EventCallback<> that is invoked before the toast appears. The callback receives a ToastBeforeOpenArgs argument.

    Remarks

    This event is triggered just before the toast notification becomes visible to the user. You can use this event to perform pre-display operations, modify toast properties, or cancel the display operation by setting the Cancel property of the event arguments. The event provides access to toast configuration and allows for last-minute customizations.

    Opened

    Gets or sets an event callback that is raised after the toast has been shown on the target container.

    Declaration
    public EventCallback<ToastOpenArgs> Opened { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<ToastOpenArgs>

    An Microsoft.AspNetCore.Components.EventCallback<> that is invoked after the toast appears. The callback receives a ToastOpenArgs argument.

    Remarks

    This event is triggered after the toast notification has been completely displayed and rendered on the target container. You can use this event to perform post-display operations, start timers, or trigger animations after the toast becomes visible. The event provides information about the opened toast and its display properties.

    Methods

    Dispose()

    Releases all resources used by the ToastEvents component.

    Declaration
    public virtual void Dispose()
    Remarks

    This method releases both managed and unmanaged resources associated with the component. It calls the overloaded Dispose(Boolean) method with true to indicate that both managed and unmanaged resources should be disposed.

    Dispose(Boolean)

    Releases the unmanaged resources used by the ToastEvents component and optionally releases the managed resources.

    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    System.Boolean disposing

    A System.Boolean value that indicates whether the method call comes from a Dispose method (true) or from a finalizer (false).

    Remarks

    This method is called by the public Dispose() method and the finalizer. When disposing is true, this method releases all resources held by managed objects that this ToastEvents references. The method also clears the reference to the parent SfToast component to prevent memory leaks.

    OnInitializedAsync()

    Method invoked when the component is ready to start.

    Declaration
    protected override Task OnInitializedAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing any asynchronous operation.

    Remarks

    This method is called during the component initialization phase and is responsible for registering the event handlers with the parent SfToast component. The method ensures that this ToastEvents instance is properly connected to its parent toast component to receive event notifications.

    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved