Thursday, 5 September 2013

Using a Layout with Partial Views MVC4

Using a Layout with Partial Views MVC4

I have an application that heavily utilises AJAX for page transitions
(effectively a pseudo SPA).
The first time the application is called, it is not by AJAX, so the
application will render a full view of that page (which gets the layout,
all the common CSS and JS). All subsequent calls are via AJAX and the same
view is rendered as a Partial view (without the layout etc)
The problem is, that even within the AJAX, there are some elements that
are common. These elements must be re-rendered because the content within
them is dynamic. They are defined in partial views and are included in
each view so that when they are called via AJAX, they are re-rendered.
Is there a way to have a view be rendered with a different base layout
when it is called from the controller? Failing that, is it possible to
have a view which is called as a PartialView, still render with a Layout?

No comments:

Post a Comment