title: Is it possible to set radio button tag helper value attribute as "checked" in html?
body: <p>I was looking for a way to use the value attribute on radio button tag helper to inform if the button was checked or not, instead of using a separate field for selection. I found an answer by @Shyju to a <a href="https://stackoverflow.com/questions/34570908/radio-button-tag-helpers-in-asp-net-5-mvc-6">related question</a>. I am using a modified example of that answer to show what I mean.</p>
  
  <p>Let's say I have a viewmodel</p>
  
  <pre><code>public class ExampleViewModel
  {
      public int Id { get; set; }
      public string UserName { get; set; }
      public List&lt;UserRole&gt; Roles { get; set; }
  }
  public class UserRole
  {
      public int Id { get; set; }
      public string RoleName { get; set; }
      public bool IsSelected { get; set; }
  }
  </code></pre>
  
  <p>that is initialized in controller</p>
  
  <pre><code>public IActionResult Example()
      {
          var vm = new ExampleViewModel
          {
              Roles = new List&lt;UserRole&gt;
              {
                  new UserRole {Id = 1, RoleName = "Admin"},
                  new UserRole {Id = 2, RoleName = "Editor"},
                  new UserRole {Id = 3, RoleName = "Reader"}
              }
          };
          return View("Example",vm);
      }
  </code></pre>
  
  <p>and used in view</p>
  
  <pre><code>&lt;form asp-controller="Example" asp-action="Save"&gt;
      &lt;label class="label"&gt;User name&lt;/label&gt;
      &lt;div class="col-md-10"&gt;
          &lt;input asp-for="UserName" type="text" /&gt;
      &lt;/div&gt;
      &lt;label class="label"&gt;Select a Role&lt;/label&gt;
      &lt;div class="col-md-10"&gt;
          &lt;div class="btn-group" data-toggle="buttons"&gt;
              @for (var i = 0; i &lt; Model.Roles.Count; i++)
              {
                  &lt;label class="btn btn-default"&gt;
                      &lt;input asp-for="Roles[i].Id" type="radio" value="@Model.Roles[i].Id" /&gt;
                      &lt;input asp-for="Roles[i].IsSelected" type="radio" value=true /&gt;
                      @Model.Roles[i].RoleName
                  &lt;/label&gt;
              }
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;input type="submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>What I would like to achieve with this, is to be able to read the UserRole.IsSelected field in controller's post method to see if the particular UserRole was checked or not. This solution works if the user checks only one button and does not alter the choice. If the user changes selection to another, then all UserRole values the user has touched will have the IsSelected field as true.</p>
  
  <p>Is it possible to somehow set the IsSelected value with HTML to show only the button that is checked when the form is submitted or does it require a JavaScript function?</p>