【发布时间】:2012-08-13 20:17:12
【问题描述】:
我知道我可以使用 Html.BeginForm 使用如下操作参数进行 POST:
@using (Html.BeginForm("Details", "Home", new { name = Model.Name }))
我可以像这样得到:
@using (Html.BeginForm("Details", "Home", FormMethod.Get))
但我似乎不能两者兼得。我该怎么做?
更新
以下是相关表格的全部内容:
@using (Html.BeginForm("Details", "Home", new { name = Model.Name }))
{
<div style="text-align: center">
@Html.DropDownList("viewMonth",
new List<SelectListItem>(ViewBag.MonthNames))
@Html.TextBox("viewYear", Model.ViewYear, new {style = "width: 30px"})
<input type="submit" value="Go"/>
<br/>
<br/>
</div>
}
其中viewMonth 和viewYear 是操作/详细信息中的参数名称。如果我尝试
@using (Html.BeginForm("Details", "Home", new { name = Model.Name },
FormMethod.Get))
它将传递 viewMonth 和 viewYear,但不传递名称。
【问题讨论】:
-
您想以一种形式进行 GET 和 POST 吗?
-
不,请原谅我出色的沟通。我正在尝试以一种形式获取和使用操作参数(我想是 RouteValues)。
标签: asp.net asp.net-mvc razor