视图的动态数据

时间:2014-05-28 15:32:03

标签: asp.net-mvc

我有这样的观点

@model MvcMusicStore.Models.Cat

@using (Html.BeginForm("Details", "Store", FormMethod.Post,
    new
    {
        id = "CatFormID",
        data_somethingAction = @Url.Action("something1List"),
    }))
{
    <fieldset>
        <legend>CatAnimal</legend>

        <label for="something1">Select something</label>
        @Html.DropDownList("something1", ViewBag.something2 as SelectList,
         new { id = "something1ID" })

        <label for="something2">Select something</label>
        @Html.DropDownList("something1", ViewBag.something2 as SelectList,
             new { id = "something2ID" })

        <p>
            <input type="submit" value="Submit" id="SubmitID" />
        </p>

    </fieldset>
}

<script src="@Url.Content("~/Scripts/something1.js")"></script>

然而,并非控制器中的每只猫都有这样的东西2。在这种情况下,我想查看仅存在:

<label for="something1">Select something</label>
@Html.DropDownList("something1", ViewBag.something2 as SelectList,
new { id = "something1ID" })

以及在此更改:

data_somethingAction = @Url.Action("HERE"),

是否可以动态显示视图?

0 个答案:

没有答案