C
C#•4mo ago
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;
}
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" />
<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.
2 Replies
Angius
Angius•4mo ago
I assume the property is supposed to be
public bool MyBool { get; set; } = false;
public bool MyBool { get; set; } = false;
If so, a checkbox might be more appropriate than a radio button
Gipper
Gipper•4mo ago
If there is an actual checkbox type then why does the radio type look like a checkbox in the view???? I mean, I am bad at frontend but that is silly still thanks 🙂 it works
Want results from more Discord servers?
Add your server