Skip to main content
All docs
V26.1
  • DxFileInput.Visible Property

    Specifies whether the component is visible.

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.v26.1.dll

    Declaration

    [DefaultValue(true)]
    [Parameter]
    public bool Visible { get; set; }

    Property Value

    Type Default Description
    Boolean true

    true to display the component; otherwise, false.

    Remarks

    Disable the Visible property to hide the File Input component. You can disable the ShowSelectButton or ShowFileList property to hide only the select button or the file list.

    The following example implements an external select button and a drop zone container for the File Input component. The component is hidden when its file list is empty.

    File Input - External Drop Zone

    <div id="overviewDemoDropZone" class="custom-drop-zone">
        <span class="drop-file-icon"></span>
        <span>Drag and Drop File Here</span><span class="custom-drop-zone-separator">or</span>
        <button id="overviewDemoSelectButton" class="custom-select-button">Select File</button>
    </div>
    
    <DxFileInput Visible="FileInputVisible" 
                 FilesUploading="OnFilesUploading"
                 SelectedFilesChanged="SelectedFilesChanged"
                 ExternalSelectButtonCssSelector="#overviewDemoSelectButton"
                 ExternalDropZoneCssSelector="#overviewDemoDropZone"
                 ExternalDropZoneDragOverCssClass="custom-drop-zone-drag-over" />
    
    @code {
        bool FileInputVisible { get; set; } = false;
    
        protected void SelectedFilesChanged(IEnumerable<UploadFileInfo> files) {
            FileInputVisible = files.ToList().Count > 0;
            InvokeAsync(StateHasChanged);
        }
        async Task OnFilesUploading(FilesUploadingEventArgs args) {
            foreach (var file in args.Files) {
                /* The following code is intended for demonstration purposes only.
                Do not read a stream directly in memory to avoid performance and security-related issues. */
                using var stream = new System.IO.MemoryStream();
                await file.OpenReadStream(file.Size).CopyToAsync(stream);
            }
        }
    }
    

    Run Demo: File Input - Overview

    See Also