Live Chat Icon For mobile
Live Chat Icon

How do I set the default value in select control?

The value property in the HTML <select> control can be utilized to set the default value. 

@page "/dropdown" 

<select class="form-control" value="@defaultValue.." @onchange="@OnSelect" style="width:150px"> 

@foreach (var template in templates)
<option value=@template>@template</option> 



List<string> templates = new List<string>() { "America", "China", "India", "Russia", "England" }; 
string defaultValue = "India"; 
string selectedString = ""; 
void OnSelect(ChangeEventArgs e) 
         selectedString = "Selected Country is: " + e.Value.ToString(); 

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.