在我的控制器中,我有以下代码:
public ActionResult Index(int? videoId, int languageId = 0)
{
//Some code
}
然后在我的 .chtml 页面中,我像这样引用它:
@using (Html.BeginForm("Index", "VideoLanguage", FormMethod.Post))
{
@Html.Hidden("videoId", Model.VideoId)
@Html.Hidden("videoLanguageId", Model.SelectedLanguage.LanguageId)
<div>
@Html.DropDownListFor(model => model.SelectedLanguage.LanguageId, ViewData["LanguageId"] as SelectList)
</div>
<div>
<a href="@Url.Action("Index", "VideoLanguage",new { videoId = Model.VideoId, languageId = Model.SelectedLanguage.LanguageId })" class="linkbutton">Add Language</a>
</div>
... code keeps going
那么当我单击按钮时会发生什么,从下拉列表中选择的 LanguageId 值没有传递。原值为。