As stated in the documentation the Event OnChange for DropDownList is shown by intellisense but should not be used. However, in some situations it would be very useful to bind the value of the DropDownList and additionally have an event when the value changes, e.g. show additional inputs when a value is selected.
Currently it is either possible to have data binding to value by @bind-Value or listen for the changed event by using Value and ValueChanged.
Hi all,
We were making some improvements on the keyboard support and the OnChange event across the board, and we decided to expose it for the DropDownList as well. Its current role is to show the user action (confirmation) of the current value, so that it offers additional functionality over the standard ValueChanged event that is available everywhere in Blazor. For the dropdownlist in particular, it will let you have an event that does not prevent two-way binding, even through there will be no tangible difference with ValueChanged
Regards,
Marin Bratanov
Progress Telerik
Hello Michael,
The OnChange event we have is designed to fire when an input is blurred or the user presses Enter while in it. The DropDownList does not have an input and so such an event does not make sense for it - it will fire when ValueChanged fires, assuming we hook it up.
Thus, for such a case you should use the ValueChanged event and update the model field there, as shown in our documentation (see the last snippet): https://docs.telerik.com/blazor-ui/components/dropdownlist/events#valuechanged.
The other alternative I can suggest for you is using the new ComboBox component and its OnChange event: https://docs.telerik.com/blazor-ui/components/combobox/events#onchange. Note that there are some significant differences between the DropDownList and the ComboBox - the combo box acts more like an input.
Regards,
Marin Bratanov
Progress Telerik