@page "/dd"
<select class="form-control" @bind="@selectedString" style="width:150px">
@foreach (string template in templates)
{
<option @onclick="(()=>dosomething())" value=@template>@template</option>
}
</select>
<h5>Selected Country is: @selectedString</h5>
<h5>Selected Country is: @selectedStringDup</h5>
@code {
List<string> templates = new List<string>() { "America", "China", "India", "Russia", "England" };
string selectedString = "America";
string selectedStringDup = "";
void OnSelect (ChangeEventArgs e)
{
selectedString = e.Value.ToString();
Console.WriteLine("The selected country is : " + selectedString);
}
void dosomething()
{
selectedStringDup = "Russia" + DateTime.Now.ToString();
}
void OnSelect (MouseEventArgs e)
{
Console.WriteLine("The selected country is : " + selectedString);
}
}
which is my onclick event inside the option tag not working. Its not firing at all. neither is onchange or onselectedchange. How can we fire an event after the value in the combo box is selected?