C#C
C#2y ago
5 replies
Gipper

How can I set bool to true in Model with radio input?

I may be doing this in an unconventional way as I am still learning, but I basically have this in my model

public class myModel
{
  public myBool { get; set; } = false;
}

and I have a view based on that model that I would like to have a radio input tag that if checked will make myBool into true when the model object is submitted in the form. Something like:
<input type="radio"  name="myBool"  asp-for="myBool" value="true"  />

It doesn't have to be done this way but I would prefer it in this way.
Was this page helpful?