1

I have a web page lay out that includes 1 main panel that shows information, and a side panel that can show one of several panels based on what happens in the main panel. So for example, the main panel can show a list of projects, and you can click the project which should show an edit panel. Or you can delete the project which should show the delete panel. There's about 5 or 6 panels. This is not the whole application so I cant make the main panel a partial view.

How would I implement this? Basically I'm trying to return two views in the controller, but obviously that is not possible. My guess is that the main panel should be the view returned by the controller. But how would I be able to set the side panel then? Can I combine 2 views into 1 within 1 controller action somehow? Or should I link two controllers to 1 action? How would I do this?

I'm really new to ASP.NET MVC but I'm having trouble googling an answer myself. Thank you for your patience.

abatishchev
  • 98,240
  • 88
  • 296
  • 433
garma
  • 213
  • 1
  • 3
  • 12

2 Answers2

0

In this case you could use a ViewModel to collect multiple Domain Models and pass them to the view as detailed here (this is what I would do). Equally you could just pass the main panel object as the strongly typed object and use ViewData to pass other data items. You could then use separate partial views for the individual panels, rendering them by passing data using

@{ Html.RenderPartial("ViewName", dataItem); }
abatishchev
  • 98,240
  • 88
  • 296
  • 433
AlexC
  • 10,676
  • 4
  • 37
  • 55
  • thanks; I considered that last option; wouldnt that result in a pretty big switch-statement that would have to figure out which panel to show in other words the controllers job? – garma Apr 01 '12 at 13:14
  • Well the partial view only needs a string to define the view render and that could be passed from the controller rather than having lots of logic on the view. – AlexC Apr 01 '12 at 15:12
0

Data-wise you would use a pass a single view model object containing data for different panels as @AlexC mentioned.

UI-wise you can use the tabs jquery plug-in to render different panels like shown here - http://jquerytools.org/demos/tabs/index.html

Gautam Jain
  • 6,789
  • 10
  • 48
  • 67