MVC 4从Partial View中获取Parent的数据

时间:2016-05-04 07:20:34

标签: c# asp.net asp.net-mvc

我的案例如下: 父页面如下所示:

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

在_SelectCase中我想基于DropDownList选择的元素加载一些数据。 为此,我有_SelectCase喜欢

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

和控制器一样

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

问题是:如何从Controller中的SelectCase方法中获取DropDownlist中的值?

感谢。

1 个答案:

答案 0 :(得分:1)

据我所知,您不能在父级内部拥有动态部分。 在服务器端调用之后生成父视图和部分视图。 您可以做的最好的事情是在父级中创建部分表单,并具有您希望通过AJAX调用动态获取的任何值。