Please consider I have 2 forms which will put in single view which are student form and teacher form. Each has different form action. I need to pass these 2 models from controller at once. So i decide to take the 2 into a new model class:
Public Class StudentTeacher
Public Student As ClsStudent
Public Teacher As ClsTeacher
End Class
And send the model from the controller:
Return View(New StudentTeacher With {.Student = New ClsStudent, .Teacher = New ClsTeacher })
And in the view I have 2 partial view one for student form and one for teacher form. For the student form would be like this:
@ModelType Model.StudentTeacher
@Using Html.Beginform()
....
@Html.TextBoxFor(Function(m) m.Student.name)
....
End Using
This view works good only the problem is the id for each element will include the model name, so the input for student name will be:
<input id="student.name">
So when the form got submitted, the controller will receive it as model of 'StudentTeacher' instead of 'Student'. What I want for this student form is send the student model only. The teacher can be sent in different form in the same view. Any suggestion to fix this? Thank you very much...!