views:

60

answers:

2

Recently I made a little site and want to rewrite it using ASP.NET MVC. At the same time I am going make some improvements: insert site map path, hierarchical menu on the side (current article should be selected) etc.

Should I use individual ContentPlaceHolder for each such page part or just use one and create such large view model for my page?

+1  A: 

What version of MVC? If you are using 2, look into RenderAction

Martin
MVC 2.0. I'll check your link.
JohnKZ
If he's using master pages, ContentPlaceHolder is still an entirely valid mechanism in MVC.
Kirk Woll
If the content in the place holder is going to be the same on all pages ... use a RenderAction.
Martin
I think I should use placeholders, cause of hierarchical menu will be different depending on article id.
JohnKZ
And I can use RenderAction, for instance, for a tag cloud in the left place holder (which also contains menu)
JohnKZ
@Martin and @JonhKZ Personally, I think overuse of RenderAction is ill-advisable. There's absolutely nothing wrong with it, but it does require a complete re-traversal of the ASP.NET MVC content pipeline and has some (mostly minor) performance implications related to it. The ContentPlaceHolder is still completely appropriate for use in MVC, regardless of version.
Nathan Taylor
+1  A: 

The ContentPlaceHolder is still a perfectly valid ASP.NET control in the Webforms view engine.

While there are cases where RenderAction is a good/better option, one can reasonably argue that RenderAction should be used with some reservation due to the fact that it re-initiates the ASP.NET MVC request pipeline with each call. It is, for example, not ideal to have 8 calls to RenderAction on every page load.

Nathan Taylor
Thanks for your comment
JohnKZ