views:

28

answers:

2

How can I tell the viewengine to look for editortemplates in another area that is in another web project?

A: 

Have you tried putting full path to the template (~/Areas/YourArea/Views/...) in UIHintAttribute?

Update:

I assume the code (link in the comments below) comes from one application, while the actual template resides in a different application. IMHO this just won't work. You might want to google for sharing templates between applications but I think the only valid solution is not to share a template but add extension methods to HtmlHelper and share those.

Jakub Konecki
This approach did not work for me
Marcus
@Marcus - Are you keeping your templates in the Shared folder?
Jakub Konecki
I Have two different web projects so the template folders is not shared between the projects. The goal is to have a kinda dashboard project/area and I would like to use editortemplates from my main projects/area
Marcus
@Marcus - so you should change your question - it's not about reusing templates from another area, but from another project!
Jakub Konecki
Well I thought it did not matter because I register the area the way you should, but maybe asp.net works differently if the area is in the same project?
Marcus
@Marcus - Could you post your RegisterRoute code - how do you register a route from another application?
Jakub Konecki
This is from my global.asax http://codepaste.net/1f4r4o and this is my area registration http://codepaste.net/uca4ig
Marcus
@Marcus - I assume the code comes from one application, while the actual template resides in a different application. IMHO this just won't work. You might want to google for sharing templates between applications but I think the only valid solution is not to share a template but add extension methods to HtmlHelper and share those.
Jakub Konecki
A: 

You could specify the path when including the editor template:

<%: Html.EditorFor(x => x.SomeProp, "~/areas/somearea/views/editortemplates/test.ascx") %>

Or use the UIHint attribute on the model property.

Darin Dimitrov
I use the UIHint attribute on my model but it seems like I must have my templates in main project?
Marcus