I have two forms, PreRegister.html and Register.cshtml.
PreRegister has a RadioButton group and I am trying to pass the user's selection - along with the CourseId that they had chosen to the Register controller/Form.
PreRegister.cshtml contains the following code:
<input checked="checked" id="rbGrp" name="rbGrp" type="radio" value="1" /><label><b>Yes</b></label>
<input id="rbGrp" name="rbGrp" type="radio" value="2" /><label><b>No</b></label>
In my controller, I want to capture the user's selection plus the CourseId that had been passed into the PreRegister controller and then pass these values in an object to the full Register controller/form
This is what I have so far:
public ActionResult PreRegister(int id)
var viewModel = new RegistrationViewModel();
viewModel.Enrollment.CourseId = id;
public ActionResult PreRegister(RegistrationViewModel viewModel)
var enrollment = new Enrollment();
enrollment.CourseId = viewModel.Enrollment.CourseId;
enrollment.IsHdco = viewModel.Enrollment.IsHdco
//how to get IsHdco value from user selection of rbGrp?
return RedirectToAction("Register", viewModel?? enrollment??);
//how to pass the enrollment object over to Register?
public ActionResult Register(int id)
CodeCamper.Model.Course course = _coursesRepository.GetById(id);
var viewModel = new PageContentViewModel();
viewModel.PageContent = course.Description;
viewModel.Course = course;
So I have 2 questions:
How do I get the value of the user selection from the radiobox group and translate it into a true/false?
How to I put this value plus CourseId into an object - either viewModel or Enrollment or something else and then transfer that as a parameter to the Register Controller that I want to geo to next?
Any help in figuring this out greatly appreciated.