I have 2 forms on a page, they are included in the masterpage like so:
Html.RenderAction("Form1", "Controller")
and
Html.RenderAction("Form2", "Controller")
The Controller has the following:
<ChildActionOnly()>
Function Form1() As ActionResult
Return View("Form1", New ModelObject())
End Function
<ChildActionOnly()> <AcceptVerbs(HttpVerbs.Post)>
Function Form1(ByVal formCollection As FormCollection) As ActionResult
Return View("Form1", New ModelObject())
End Function
<ChildActionOnly()>
Function Form2() As ActionResult
Return View("Form2", New ModelObject())
End Function
<ChildActionOnly()> <AcceptVerbs(HttpVerbs.Post)>
Function Form2(ByVal formCollection As FormCollection) As ActionResult
Return View("Form2", New ModelObject())
End Function
The forms markup in the ascx is as follows, they are essentially the same form so the markup is very similar:
<% Using Html.BeginForm()%>
<%= Html.TextBoxFor(Function(model) model.Property1, New With {.class = "input"})%>
<input type="submit" class="submitbutton" value="" name="submit" />
<% End Using%>
The problem is, when I submit either form, it runs both post methods.
So Form1 post and Form2 post, yet the values in the form collection are from which ever form was submitted.
My question is: Why is this submitting both forms with one set of form data? How can I make it call only the relevant action with the correct form data?
I am sure I am making a simple mistake, just cannot see it for looking.
Project that demonstrates the problem can be found here: TestMVC.zip
Thanks in advance.