Answer the question
In order to leave comments, you need to log in
Is there a strongly typed way to reuse Razor code in ASP.Net MVC?
Hello!
I have partial actions in my project (ActionResult PartialAction(){ return PartialView(); }) and Razor views that I use in other views with calls to type:
Html.RenderAction("ActionName","Controller",new { x = 1, y=2, z=3})
Html.RenderPartial("~/Views/Controller/ViewName",new { a=10, b=20, c=30})
public static class HelperExtensions
{
public static MvcHtmlString RenderABC(this HtmlHelper self, int a,int b, int c)
{
return self.Partial("~/Views/Controller/ViewName",new { a, b, c});
}
}
Html.RenderPartial("~/Views/Controller/ViewName",new { a=10, b=20, c=30})
Html.RenderABC(10,20,30)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question