0

I have a case like the following: The Parent page looks like:

    @using (Html.BeginForm("Create", "HTML", FormMethod.Post))
    {
    @Html.DropDownListFor(model => model.SelectedObjectId, Model.MajorObjects)
    @Html.Partial("_SelectCase");
    ...
    }

And in the _SelectCase i want to load some data based on the DropDownList selected element. For this i have the _SelectCase like

@using (Html.BeginForm("SelectCase", "HTML", FormMethod.Post))
{
...
}

And the controller like

public ActionResult SelectCase(CustomIdentity currentUser)
        {
         ...
        }

And the question: how may i get the value from the DropDownlist in the SelectCase method from the Controller?

Thanks.

Jake Manet
  • 1,174
  • 3
  • 15
  • 26
  • 1
    Nested forms are invalid html and not supported. –  May 04 '16 at 07:22
  • How may i solve this? – Jake Manet May 04 '16 at 07:23
  • 1
    And to respond to client side events (selecting an option) you need to use javascript, and if you want the view to be updated based on the selected option, you need ajax to call a server method that returns a partial view. –  May 04 '16 at 07:23
  • Ok, thanks for answer. – Jake Manet May 04 '16 at 07:25
  • @JohnStab Explain what you want to achieve in your post, maybe there is an easier work around than having to use multiple forms. Why do you need a form around your dropdownlist? – Brendan Vogt May 04 '16 at 07:37
  • I want to update the Partial View based on the selected value in DropDown... – Jake Manet May 04 '16 at 07:44
  • See: http://stackoverflow.com/questions/20799658/how-can-i-pass-parameters-to-a-partial-view-in-mvc-4 – Aliz May 04 '16 at 08:04

1 Answers1

2

As far as I know, you can't have a dynamic partial inside a parent. Parent and Partial views are generated after a server side call. The best you can do is make that partial form in the parent and have whatever values you want to change dynamically fetched through an AJAX call.