在我的控制,我有以下代碼:Url.Action不傳遞參數指標
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值不會被傳遞。原始值是。
你不這樣做是正確的。你能在這裏發佈你的模型的代碼嗎?如果你這樣做,我會告訴你如何以正確的方式做到這一點。 – ataravati