ASP.NET MVC 3 - How to submit an ajax form embedded in an html form

I have an ASP.NET MVC 3 project and a problem with one of my Create views.

I have cascading drop-down fields that I have implemented using ajax forms.

Speaking roughly - like this:

@using (Html.BeginForm(...)) { @Html.MyDropDown1 using (Ajax.BeginForm(...)) { @Ajax.MyDropdown2 <input type="submit" value="Select" /> } using (Ajax.BeginForm(...)) { @Ajax.MyDropdown3 <input type="submit" value="Select" /> } <!-- other form fields --> <input type="submit" value="Create" /> } 

The problem is that the submit buttons inside ajax forms actually represent the external html form.

Can I specify the name of the form I want to submit?

I was thinking about putting my ajax forms above my html form, so there would be no nesting - but I need the values โ€‹โ€‹of the dropdown selected elements in my html article.

Thanks Pete

+7
source share
1 answer

As stated in the comments, you cannot have nested forms. Remove all bits using (Ajax.BeginForm(...)) and process your ajax calls through jQuery (or something else).

+7
source

All Articles