ビューに渡されるモデルの一部ではない状態を保持して、選択リストを作成する必要があります。ViewBagを使用してリストをビューに渡す必要があると思いますか?実装と選択リストの状態を保持する方法(選択した値をアクションに戻し、ビューに再度渡す方法(これを行うための可能な方法))に関するアドバイスはありますか?
現在のアクション:
public ActionResult Images(string x, string y)
{
//some code
ContentPage cp = this.ContentPage;
return View(cp);
}
//Post to action with same name:
[HttpPost]
public ActionResult Images(string someParameter)
{
ContentPage cp = this.ContentPage;
return View(cp);
}
現在のビュー:
@model ContentPage
@{
ViewBag.Title = "Images";
CmsBaseController controller = (this.ViewContext.Controller as CmsBaseController);
}
@using (Html.BeginForm())
{
<div>
//This should go to List<SelectListItem> as I understand
<select name="perpage" id="perpage" onchange='submit();'>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</div>
}
ありがとうございました!!!