0

I have a menu that loads PartialView's into Content area.

I load PartialView's because I only want the Content area to change. The pros is the selected menuitem is always highlighted and things like collapsed doesn't change either.

One of my problems is that Sections by design doesn't work for PartialView's. I have a header in the Content area for some of the PartialView's but not all, and I could be nice to Sections for this because that's what they are there for right.

I'm wondering if I ever make a regular View and it feels wrong I don't use them, when it's so fundamental in MVC.

My question is, would you load View or PartialViews into Content area? If you prefer View, what is best practice to solve the issue with persistent the menu state. (Session object or hashtag some kind of ViewBag that is able to survive a pagerefresh)?

radbyx
  • 9,352
  • 21
  • 84
  • 127

1 Answers1

1

Everything is a view. The only distinction between whether it's a partial view or just a view is in how you use it. If you return PartialView from an action or use Html.Partial, then you have a partial view. Otherwise, you're using a full view (which merely means that whatever layout is set to be loaded will be utilized).

Essentially, your question is moot. Using a "view" in the way you're using "partial views", makes it a partial view. The only way you could use a "view" is if you add the full site layout into your content area, which would obviously not be something you want.

Also, in terms of sections, using sections in a "partial view" is a functional limitation caused by the fact that it's a partial view. Sections only work in conjunction with a layout, since partial views don't employ a layout, there's no way to employ sections.

Chris Pratt
  • 232,153
  • 36
  • 385
  • 444
  • Let's say you have clicked a menuitem and but a CSS class on it so it's hightlighted from the others. If you load a View the whole page reloads and you lose the highlight. How would you work around this? if you would at all? Or would you keep loading partial views like i am now? But then i can't load any views at all.. – radbyx Feb 20 '15 at 15:27
  • I am sorry if my question is weak, I guess I am both trying to figuring out what practice to choose and how to solve the View/menu issue gives when loading a new page. – radbyx Feb 20 '15 at 15:29