views:

74

answers:

2

Hey MVC experts.

I two database entities that i need to represent and i need to output them in a single page.

I have something like this

Views Def ViewA ViewB Test ViewC

I want to ViewC to display ViewA, which displays ViewB.

Right now i'm using something like this:

// View C
<!-- bla -->
<% Html.RenderPartial(Url.Content("../Definition/DefinitionDetails"), i); %>


// View A
<!-- bla -->
<% Html.RenderPartial(Url.Content("../Definition/DefinitionEditActions")); %>

Is there a better to do this? I find that linking with relative pathnames can burn you. Any tips?

Any chance I can make somehtiing like...

Html.RenderPartial("Definition","DefinitionDetails",i); ?

Thanks for the help

A: 

Could you not copy the partials into the shared folder then just do:

<% Html.RenderPartial("DefinitionDetails", i); %> and

<% Html.RenderPartial("DefinitionEditActions"); %>

ridecar2
Yea i could, but is that the correct way?
George
Seeing as you want to access the view from multiple controllers I would say so.
ridecar2
+1  A: 

You can refer to Views with full paths, like:

Html.RenderPartial("~/Views/Definition/DefinitionDetails")

Even better, use the T4MVC library, which does the above and makes it (quasi-) strongly-typed. You can refer to any view from any controller or view. You use it like this:

Html.RenderPartial(MVC.Definition.Views.DefinitionDetails)

or

Html.RenderPartial(MVC.Definition.Views.DefinitionDetails, myModel)
Matt Sherman