I have an enum and a variable of the enum type as follows:
private enum Cities {Berlin, Madrid, Paris, Vienna}
private Cities City;
In the html I have a InputSelect component as follows:
<InputSelect @bind-Value="City">
@foreach(var city in Enum.GetValues(typeof(Cities)))
{
<option value="@city">@city</option>
}
<br />
@City
This is working fine, and each time I select another city the variable city is updated.
The issue I have is that I need to execute some tasks when a new city is selected. So I need to attach a function to the InputSelect. I cannot add ValueChanged because of the binding. I tried also the following:
<InputSelect ValueChanged="(e)=>TestFunction(e)">
@foreach(var city in Enum.GetValues(typeof(Cities)))
{
<option value="@city">@city</option>
}
</InputSelect>
I don't know what to do to make it work. Maybe someone has an idea.