menu

Blazor

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

    Show / Hide Table of Contents

    Class ToastBeforeOpenArgs

    Specifies the event arguments for the Toast before open event.

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

    This class provides data for the event that is raised before a Toast notification is displayed. It allows you to cancel the opening of the Toast or modify its options programmatically.

    Examples
    <SfToast @ref="ToastRef">
        <ToastEvents TValue="ToastModel" OnOpen="@OnBeforeOpen"></ToastEvents>
    </SfToast>
    
    private void OnBeforeOpen(ToastBeforeOpenArgs args)
    {
        // Cancel opening based on some condition
        if (SomeCondition)
        {
            args.Cancel = true;
        }
    
        // Modify toast options
        if (args.Options != null)
        {
            args.Options.Content = "Modified content";
        }
    }

    Constructors

    ToastBeforeOpenArgs()

    Declaration
    public ToastBeforeOpenArgs()

    Properties

    Cancel

    Gets or sets a value indicating whether the Toast opening should be cancelled.

    Declaration
    public bool Cancel { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if the Toast should be prevented from opening; otherwise, false. The default value is false.

    Remarks

    Setting this property to true prevents the Toast from being displayed to the user. This is useful for implementing conditional logic where certain Toast notifications should not appear based on application state or user preferences.

    Options

    Gets or sets the current Toast model properties as options.

    Declaration
    public ToastModel Options { get; set; }
    Property Value
    Type Description
    ToastModel

    An instance of ToastModel representing the configuration options for the Toast notification. Can be null.

    Remarks

    This property provides access to the Toast configuration that will be used when the Toast is displayed. You can modify these options programmatically before the Toast opens to customize its appearance, content, or behavior. Common modifications include changing the content, title, timeout duration, or CSS classes.

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