Live Chat Icon For mobile
Live Chat Icon

How do I set the default value in select control?

The property value in the select control can be used to set the default value in 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>


	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();

Share with

Related FAQs

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

Please submit your question and answer.