Blazor: How to use the onchange event in <select> when using @bind also?

后端 未结 6 1595
暖寄归人
暖寄归人 2021-02-12 17:33

I need to be able to run a function after a selection in made in a

@code {

    private string selectedItem {get; set;}

    private string CheckSelected
    {
        get
        {
            return selectedItem;
        }
        set
        {
            ChangeEventArgs selectedEventArgs = new ChangeEventArgs();
            selectedEventArgs.Value = value;
            OnChangeSelected(selectedEventArgs);
        }
    }

    private void OnChangeSelected(ChangeEventArgs e)
    {
        if (e.Value.ToString() != string.Empty)
        {
            selectedItem = e.Value.ToString();
        }
    }

}

提交回复
热议问题