存储要在ViewData中显示的正确控件。至于菜单的保存,
您的选择是缓存(多个会话使用)、会话(仅此会话使用)或tempdata(仅用于此会话中的下一个方法)。或者,您可以将它缓存在数据层中。通常,我只是重新蚀刻数据,直到它成为性能问题——通常不会。
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(FormCollection collection)
{
var filterType = Request.Form["FilterSelect"];
ViewData["FilterChosen"] = filterType;
PopulateSelectionFiltersData();//This method fills up the drop down list
string userControl = "DefaultControl";
switch (filterType)
{
case "TypeA":
userControl = "TypeAControl";
break;
...
}
ViewData["SelectedControl"] = userControl;
return View();
}
<% Html.RenderPartial( ViewData["SelectedControl"], Model, ViewData ); %>