I need to create a select list, preserving the state, which is not part of the model passed to the view. I suppose I should be using a ViewBag to pass a List to the View ? Any advise on implementation and how to preserve the state of the select list (how do I pass the selected value back to action and to the view again (possible ways of doing this) ?
The Action as of now:
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);
}
The view as of now :
@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>
}
Thank you!!!