I am sending parameters to the GET ActionResult like this:
public ActionResult MyFormLetter(string studentName, string teacherName, string courseName, string appointmentDate)
{
// Do stuff here;
}
After clicking on a form button that calls the POST ActionResult, those values are out of scope. Ho can I retain the values in the GET ActionResult to reuse in the Post ActionResult?
Thanks for any help!
You should be using a ViewModel for this, as well as a strongly-typed View. Something like this would work:
Your Action methods would look like this:
And a little View code:
When you reach the Action method from the POST of the submit, you will then have access to all of that data that was input into your form view.
Disclaimer: The View code just shows the necessary elements to show how data is saved in the model for Model Binding.