@page "/"
<h1>Hello, world!</h1>
Welcome to your new app.
<EditForm Model=selectedString>
<InputSelect ValueExpression="@(()=> selectedString)"
Value="@selectedString"
ValueChanged="@((string value) => OnValueChanged(value ))">
<option value="">select...</option>
@foreach (var country in templates)
{
<option value="@country">@country</option>
}
</InputSelect>
<span>@selectedString</span>
</EditForm>
@code{
private List<string> templates { get; set; } = new List<string>() { "America", "China", "India", "Russia", "England" };
private string selectedString { get; set; } = "America";
private Task OnValueChanged(string value)
{
// Assign the selected value to the Model
selectedString = value;
return Task.CompletedTask;
}
}