alexa
menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Search Results for

    Show / Hide Table of Contents

    Class ChatUIAttachment

    Inheritance
    object
    ComponentBase
    OwningComponentBase
    SfOwningComponentBase
    ChatUIAttachment
    Implements
    IComponent
    IHandleEvent
    IHandleAfterRender
    IDisposable
    Inherited Members
    ComponentBase.Assets
    ComponentBase.AssignedRenderMode
    ComponentBase.DispatchExceptionAsync(Exception)
    ComponentBase.InvokeAsync(Action)
    ComponentBase.InvokeAsync(Func<Task>)
    ComponentBase.OnAfterRender(bool)
    ComponentBase.OnAfterRenderAsync(bool)
    ComponentBase.OnInitialized()
    ComponentBase.OnParametersSetAsync()
    ComponentBase.RendererInfo
    ComponentBase.SetParametersAsync(ParameterView)
    ComponentBase.ShouldRender()
    ComponentBase.StateHasChanged()
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    OwningComponentBase.IsDisposed
    OwningComponentBase.ScopedServices
    Namespace: Syncfusion.Blazor.InteractiveChat
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class ChatUIAttachment : SfOwningComponentBase, IComponent, IHandleEvent, IHandleAfterRender, IDisposable

    Constructors

    ChatUIAttachment()

    Declaration
    public ChatUIAttachment()

    Properties

    AllowDragAndDrop

    Gets or sets a value indicating whether drag-and-drop is enabled for attachments.

    Declaration
    [Parameter]
    public bool AllowDragAndDrop { get; set; }
    Property Value
    Type Description
    bool

    A bool indicating whether users can drag files into the upload area. The default value is false.

    Remarks

    When enabled, users can drag files from their file system directly into the chat area to initiate upload.

    Disable this setting if drag-and-drop conflicts with other gestures or custom UI interactions.

    Examples
    <SfChatUI>
        <ChatUIAttachment AllowDragAndDrop="true" />
    </SfChatUI>

    AllowedFileTypes

    Gets or sets the allowed file types for attachments.

    Declaration
    [Parameter]
    public string AllowedFileTypes { get; set; }
    Property Value
    Type Description
    string

    A string containing a comma-separated list of allowed file extensions (e.g., ".jpg,.png,.pdf"). The default value is "" (empty string), which allows all file types.

    Remarks

    Use this property to restrict uploads to specific extensions. Validation is performed client-side and should be reinforced on the server.

    When left empty, all file types are permitted, subject to server-side validation and security policies.

    Examples
    <SfChatUI>
        <ChatUIAttachment AllowedFileTypes=".jpg,.png,.pdf,.docx" />
    </SfChatUI>

    AttachmentTemplate

    Gets or sets a custom template for rendering attachments in the footer.

    Declaration
    [Parameter]
    public RenderFragment<AttachmentTemplateContext> AttachmentTemplate { get; set; }
    Property Value
    Type Description
    RenderFragment<AttachmentTemplateContext>

    A RenderFragment<TValue> that defines the HTML structure or rendering logic for attachments. The default value is null, which renders the default attachments display.

    Remarks

    The AttachmentTemplate property allows you to customize how attachments are displayed in the footer. It accepts a RenderFragment<TValue> that provides complete control over the rendering of attachment elements, including thumbnails, icons, file metadata, and other attachment-related information.

    When null, the component renders attachments using the default template. Provide a custom RenderFragment<TValue> to override the default rendering behavior.

    The context parameter passed to the template is of type AttachmentTemplateContext, which contains all necessary data for rendering each attachment.

    Examples

    The following example demonstrates how to define a custom attachment template:

    <SfChatUI>
        <AttachmentTemplate>
            @if (context?.Attachments != null)
            {
                @foreach (var attachment in context.Attachments)
                {
                    <div class="attachment-item">
                        <span class="attachment-icon">📎</span>
                        <span class="attachment-name">@attachment.Name</span>
                        <span class="attachment-size">(@attachment.Size)</span>
                    </div>
                }
            }
        </AttachmentTemplate>
    </SfChatUI>

    Enable

    Gets or sets a value indicating whether the attachment feature is enabled.

    Declaration
    [Parameter]
    public bool Enable { get; set; }
    Property Value
    Type Description
    bool

    A bool indicating whether attachments can be uploaded and managed. The default value is false.

    Remarks

    When set to true, users can upload and manage attachments in chat.

    When set to false, the attachment functionality is disabled and all related UI and operations are unavailable.

    Examples
    <SfChatUI>
        <ChatUIAttachment Enable="true" />
    </SfChatUI>

    MaxFileSize

    Gets or sets the maximum file size, in bytes, for attachments.

    Declaration
    [Parameter]
    public double MaxFileSize { get; set; }
    Property Value
    Type Description
    double

    A double representing the maximum allowed file size in bytes. The default value is 30000000 (approximately 30 MB).

    Remarks

    Uploads exceeding this size are rejected by the component before sending the request.

    Ensure your server configuration (e.g., request size limits) is compatible with this setting.

    Examples
    <SfChatUI>
        <ChatUIAttachment MaxFileSize="10485760" /> <!-- 10 MB -->
    </SfChatUI>

    MaximumCount

    Gets or sets the maximum number of attachments allowed per message.

    Declaration
    [Parameter]
    public int MaximumCount { get; set; }
    Property Value
    Type Description
    int

    An int indicating the upper limit of files that can be added to a single message. The default value is 10.

    Remarks

    The value must be a positive integer. Values less than 1 should be treated as 1.

    When the attachment count reaches this limit, additional uploads should be blocked until files are removed.

    Examples
    <SfChatUI>
        <ChatUIAttachment MaximumCount="5" />
    </SfChatUI>

    Path

    Gets or sets the path used for storing and serving attached files.

    Declaration
    [Parameter]
    public string Path { get; set; }
    Property Value
    Type Description
    string

    A string representing the server path (or virtual path) for file storage and retrieval. The default value is "" (empty string).

    Remarks

    Defines the location where uploaded files are stored and from which they are served (e.g., for previews or downloads).

    If both SaveFormat and Path are configured, the Path value typically dictates the storage location and takes precedence for file resolution.

    Examples
    <SfChatUI>
        <ChatUIAttachment Path="/uploads/chat/" />
    </SfChatUI>

    RemoveUrl

    Gets or sets the server URL for removing attachments.

    Declaration
    [Parameter]
    public string RemoveUrl { get; set; }
    Property Value
    Type Description
    string

    A string representing the server endpoint for file removal. The default value is "" (empty string).

    Remarks

    This URL must point to a server endpoint that can process attachment deletion requests.

    If left empty, server-side removal cannot be performed and previously uploaded files will not be deleted via the component.

    Examples
    <SfChatUI>
        <ChatUIAttachment RemoveUrl="https://example.com/api/remove" />
    </SfChatUI>

    SaveFormat

    Gets or sets the format in which attachments are saved.

    Declaration
    [Parameter]
    public SaveFormat SaveFormat { get; set; }
    Property Value
    Type Description
    SaveFormat

    A SaveFormat specifying how files are persisted. The default value is Blob.

    Remarks

    Controls the server-side representation of uploaded files, such as binary blobs or Base64.

    Select a format that aligns with your storage and processing requirements.

    Examples
    <SfChatUI>
        <ChatUIAttachment SaveFormat="SaveFormat.Base64" />
    </SfChatUI>

    SaveUrl

    Gets or sets the server URL to which attachments will be uploaded.

    Declaration
    [Parameter]
    public string SaveUrl { get; set; }
    Property Value
    Type Description
    string

    A string representing the server endpoint for file uploads. The default value is "" (empty string).

    Remarks

    This URL must point to a server endpoint capable of processing multipart/form-data uploads.

    If left empty, upload requests cannot be performed and attachment upload will not function.

    Examples
    <SfChatUI>
        <ChatUIAttachment SaveUrl="https://example.com/api/upload" />
    </SfChatUI>

    Methods

    BuildRenderTree(RenderTreeBuilder)

    Declaration
    protected override void BuildRenderTree(RenderTreeBuilder __builder)
    Parameters
    Type Name Description
    RenderTreeBuilder __builder
    Overrides
    ComponentBase.BuildRenderTree(RenderTreeBuilder)

    Dispose(bool)

    Dispose unmanaged resources in the Syncfusion Blazor component.

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

    Boolean value to dispose the object.

    Overrides
    OwningComponentBase.Dispose(bool)

    OnInitializedAsync()

    Method invoked when the component is ready to start.

    Declaration
    protected override Task OnInitializedAsync()
    Returns
    Type Description
    Task

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

    Overrides
    ComponentBase.OnInitializedAsync()

    OnParametersSet()

    Declaration
    protected override void OnParametersSet()
    Overrides
    ComponentBase.OnParametersSet()

    Implements

    IComponent
    IHandleEvent
    IHandleAfterRender
    IDisposable
    In this article
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved