How to handle nested forms in ASP.NET MVC

asp.net-mvc-3

I'm trying to build a fairly complex form which as a couple of cascading selects – i.e. the user selects a value in one combo and the other combo is populated according to their first selection.

I've followed a tutorial on how to handle the cascading but the problem I have is that I now have nested forms (the code in the tutorial uses forms inside partial views to POST to a controller action to load the 2nd combo). I have my main form on which I want to collect the input values but also the nexted forms for the cascading select boxes. The problem I have is that the cascading selection doesn't post to the correct controller action, but instead posts to my main (outer) form's action.

I understand this is the correct behaviour for a browser (as nested forms apparently aren't supported) but what's the correct way to implement this?

Best Answer

The correct way is to only have one form. Then use AJAX to populate the cascading drop down list. The are 100s of examples online how to do this with JSON

Related Topic