We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to disable clear button programmatically from a method

Hi!

I would like to disable the clear button in the SfUploader component programmatically from a method that I created. Is that possible? If so, how can I achieve that?

Thanks in advance. 


3 Replies 1 reply marked as answer

UD UdhayaKumar Duraisamy Syncfusion Team March 21, 2023 06:25 AM UTC

Yes, you are able to disable the Clear button of the File Upload component from another method using JS Interop, as shown in the code snippet below.


[Index.js]

@using Syncfusion.Blazor.Inputs

@using System.IO

@inject IJSRuntime JSRuntime

 

<div style="margin:130px auto;width:300px">

    <button class="e-btn" @onclick="DiableClearButton">Disable Clear Button</button>

    <br />

    <SfUploader ID="UploadFiles" AutoUpload="false"></SfUploader>

</div>

 

@code{

    public async Task DiableClearButton()

    {

        await JSRuntime.InvokeAsync<object>("disableButton");

    }

}


[Script]

function disableButton()

    {

       document.getElementsByClassName('e-file-clear-btn')[0].disabled = true;

    }