Для этого вы должны использовать ViewModel, а также строго типизированный View. Примерно так будет работать:
public class StudentInformation
{
public string StudentName { get; set; }
public string TeacherName { get; set; }
public string CourseName { get; set; }
public string AppointmentDate { get; set; }
}
Ваши методы действий будут выглядеть так:
public ActionResult MyFormLetter()
{
return View();
}
[HttpPost]
public ActionResult MyFormLetter(StudentInformation studentInformation)
{
// do what you like with the data passed through submitting the form
// you will have access to the form data like this:
// to get student's name: studentInformation.StudentName
// to get teacher's name: studentInformation.TeacherName
// to get course's name: studentInformation.CourseName
// to get appointment date string: studentInformation.AppointmentDate
}
И немного Посмотреть код:
@model StudentInformation
@using(Html.BeginForm())
{
@Html.TextBoxFor(m => m.StudentName)
@Html.TextBoxFor(m => m.TeacherName)
@Html.TextBoxFor(m => m.CourseName)
@Html.TextBoxFor(m => m.AppointmentDate)
<input type="submit" value="Submit Form" />
}
Когда вы достигнете метода Action из POST отправки, вы получите доступ ко всем тем данным, которые были введены в представление формы.
Отказ от ответственности: код View просто показывает необходимые элементы, чтобы показать, как данные сохраняются в модели для привязки модели.