I am using MVC2 in VS2010 with .Net 4.0. I have a situation in which I will have a bunch of partial views that I need to all have the same template. Basically I need them all wrapped with the same DIV (and other junk). I just want one place to change this DIV... so I used a master page. It works great, all the partial views use that master, and if I need to change something its no problem.
Problem space: I need to have some of the View specific data, in this case its the Id of the record the view displays, shown in the Id id the DIV. Now I realize I could just create another placeholder, but I need this id to be in 10 places, not 1.
<div id="<%: ViewObjectId %>">
<asp:contentplaceholder id="ViewStuff" runat="server"/>
</div>
I have tried to add the Id to the ViewData, however it seems in MVC2 the ViewData is missing in action.
I could create a parent Action that calls a child view, but the problem with that is it takes away from the flexibility of having any parameters I want... all views would have to use the same signature.
Any thoughts or suggestions?