This code will help you to understand how to set the default value in select control.
The property value in the select control can be used to set the default value in the select control.
@page "/dropdown" <select class="form-control" value="@defaultValue " @onchange="@OnSelect" style="width:150px"> @foreach (var template in templates) { <option value=@template>@template</option> } </select> <h5>@selectedString</h5> @code { List<string> templates = new List<string>() { "America", "China", "India", "Russia", "England" }; string selectedString = ""; string defaultValue = "India"; void OnSelect(ChangeEventArgs e) { selectedString = "Selected Country is: " + e.Value.ToString(); } }
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
The property value in the select control can be used to set the default value in the select control.
need an explanation for this answer? contact us directly to get an explanation for this answer