Search code examples
asp.net-mvcasp.net-mvc-3razorrenderpartial

how to render Partial with inheritence in MVC 3?


I have this function in my MVC project

  ViewPage vp = new ViewPage();
          System.Web.UI.Control control = vp.LoadControl(controlName);

if i render a partial control using this function then they render only ASPX based partial control they never render Razor partial control because they are inherited by System.Web.Mvc.WebViewPage

so how i can render the partial view in MVC that can render both type of partial or just render razor partial.


Solution

  • You are correct, I don't believe you can use ASP.NET controls with the Razor engine this way. If you want to ASP.NET controls, I would use the ASP.NET engine for your MVC application instead of Razor.