title: .NET Core <select> With Default Value?
body: <p>My <strong>goal is to generate a <code>&lt;select&gt;</code> dropdown with a certain select value (<code>&lt;option&gt;</code>) pre-selected</strong>, so the finalized <code>HTML</code> should look like this:</p>
  
  <pre><code>&lt;select&gt;
    &lt;option value = "1"&gt;Option1&lt;/option&gt;
    &lt;option value = "2" selected&gt;Option2&lt;/option&gt;
    &lt;option value = "3"&gt;Option3&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>Note that the option with a value of 2 has a <code>selected</code> attribute, indicating that it will show before the dropdown is clicked. I cannot (and am trying to) achieve this using .NET Core Tag Helpers.</p>
  
  <p>This is my model (I think you can safely ignore the details):</p>
  
  <pre><code>public class ReportViewModel
  {
    [Display(Name = "Pick a form")]
    public IEnumerable&lt;Form&gt; AvailableForms { get; set; }
  
    public Form SelectedForm { get; set; }
  
    public List&lt;ReportData&gt; FormResponses { get; set; }
  }
  </code></pre>
  
  <p>Note that the <code>Form</code> object there just has <code>Id</code> and <code>Name</code> properties on it.</p>
  
  <p>This is my select statement:</p>
  
  <pre><code>&lt;label asp-for="SelectedForm.Name" class="form-control-label font-weight-bold"&gt;&lt;/label&gt;
  &lt;select asp-for="SelectedForm.Name"
          class="form-control"
          onchange ="onFormSelected(this.value)"
          asp-items="@(new SelectList(Model.AvailableForms, "Id", "Name"))"&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>I don't see the answer in the <a href="http://%20https://docs.microsoft.com/en-us/aspnet/core/mvc/views/working-with-forms#the-select-tag-helper" rel="noreferrer">Microsoft Guide</a>
  Or in a <a href="https://www.davepaquette.com/archive/2015/05/18/mvc6-select-tag-helper.aspx" rel="noreferrer">blog on the topic</a></p>