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;

    }




Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Disable_Clear_Button_Blazor_Uploader-271425399


Marked as answer

AA Aaron Aditama March 21, 2023 06:29 AM UTC

Ok, thank you for the quick response.

It's working now.



UD UdhayaKumar Duraisamy Syncfusion Team March 22, 2023 05:15 AM UTC

Glad the solution worked for you! Please get back to us if you need any further assistance.


Loader.
Up arrow icon