How do I set my RadzenTextBox to String.Empty if a toggle is clicked

661 views Asked by At
<RadzenTextBox Name="employeeSearch" class="w-100" Placeholder="Search" @oninput="@(args => Change(args.Value.ToString()))" />

I need to access this component and set the text to string.Empty programmatically.

1

There are 1 answers

0
enet On BEST ANSWER

I'm not familiar with RadzenTextBox component and its inner working, and am not completely certain that I understand your requirement... However, the following code, using an input text Html element is assigned the value of empty string, at each keystroke ( input event is triggered at each keyboard) on the keyboard.

    <input type="text" @bind-value="@Empty" @bind-value:event="oninput" />

     @code
    {
    private string empty;

    public string Empty
    {
        get => string.Empty;
        set
        {
            empty = string.Empty;
        }
    }
}

Now, you may adapt the code above in your sample...OK, I'll do it here:

    <RadzenTextBox Name="employeeSearch" class="w-100"  Placeholder="Search" @bind-value="@Empty" @bind-value:event="oninput" />
    
     @code
    {
    private string empty;

    public string Empty
    {
        get => string.Empty;
        set
        {
            empty = string.Empty;
        }
    }
}