I have always used the MVC model binding so this is new for me. I have a class and mvc razor form.
public class Student
{
public string Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public bool? IsNew { get; set; }
}
My mvc razorpage
<div class="form-group">
<label class="checkbox-inline">
<input type="checkbox" name="isNew" id="isNew">Import
</label>
</div>
<div class="form-group">
<label for="firstName">FirstName</label>
<input class="form-control" name="firstName" id="firstName"/>
</div>
The way I have binded the firstName was
student.FirstName = request.Form.Get("firstName");
But I have not been able to use the same technique for checkbox? I tried using
student.IsNew = request.Form.GetValues("isNew");
student.IsNew = request.Form.Get("isNew");
How can I do this?