1

I have number of projects that use different view engines (razor and webform). I want to share a partial view between them. I want to put my partial view in base project and just link partial views in my projects to it.

Looks like it isn't possible because partial view in razor and webform inherited from different base classes. Is it possible to hack this?

RredCat
  • 5,259
  • 5
  • 60
  • 100
  • 1
    I think this is not possible if yes this is interesting how! – ilay zeidman Jan 16 '14 at 13:31
  • Ajax can be a simple work-around. If you don't want to use ajax, there is a hack for limited capability: http://stackoverflow.com/questions/702746/how-to-include-a-partial-view-inside-a-webform – tweray Jan 16 '14 at 16:32
  • @WeTTTT It is only partly solution, because I have to share some view's specific code. – RredCat Jan 17 '14 at 22:45

1 Answers1

0

It was more simple that I though. WebForm can't take in Razor partial view. BUT Razor view engine takes in WebForm partial view. So it isn't issue at all.

What I did.

  1. Create some shared project.
  2. Add Partial.ascx file (and some js files) in sub folder of this shared project.
  3. Add reference to this project to my sub projects.
  4. Add as link partial view (and some js files) to sub projects.

So now we have partial view that is shared between number of projects.

PS: Be aware, my projects have only one view engine for improving performance. All other were removed: ViewEngines.Engines.Clear(); and added ViewEngines.Engines.Add(new RazorViewEngine()); Razor only. So I have to remove this code from my Global.asax file.

RredCat
  • 5,259
  • 5
  • 60
  • 100