I have one view in which there is a menu on the left and a container on the right side that is displayed from one of several partial views.
Right now I am facing a situation similar to the following index view:
<div class="container">
<div class="leftHandMenu">
</div>
<div class="rightHandPane">
<% if (Model.CurrentPane == "Sent") { %>
<% Html.RenderPartialView("SentPartial", Model.SomeData); %>
<% } else if (Model.CurrentPane == "Inbox") { %>
<% Html.RenderPartialView("InboxPartial", Model.SomeData); %>
<% } else if (Model.CurrentPane == "Alerts") { %>
<% Html.RenderPartialView("AlertsPartial", Model.SomeData); %>
<% } %>
</div>
</div>
with the following actions:
public ActionResult Inbox(int? page)
{
MessageListViewModel viewData = new MessageListViewModel();
viewData.SomeData = messageService.getInboxMessages(page.HasValue ? page.Value : 0);
viewData.CurrentPane = "Inbox";
return View("Index", viewData);
}
public ActionResult Alerts(int? page)
{
MessageListViewModel viewData = new MessageListViewModel();
viewData.SomeData = messageService.getAlertMessages(page.HasValue ? page.Value : 0);
viewData.CurrentPane = "Alerts";
return View("Index", viewData);
}
public ActionResult Sent(int? page)
{
MessageListViewModel viewData = new MessageListViewModel();
viewData.SomeData = messageService.getSentMessages(page.HasValue ? page.Value : 0);
viewData.CurrentPane = "Sent";
return View("Index", viewData);
}
I understand that this situation is not perfect, but I need these parts in order to remain partial. I make a bunch of ajax calls in this view to reload this “right pane” with various partial views.
"" , , "" . ViewModel, if-else .
? 3 , . , ViewModel.
-, , ? Master View , , Master View, ASP.NET MVC.
!