You could write it as an extension method to the HtmlHelper
class:
using Sysem.Web.Mvc;
using Sysem.Web.Mvc.Html;
public static class PartialHelper
{
public static void RenderMostRecent(this HtmlHelper html)
{
html.RenderAction("MostPopular", "Blog");
}
}
and then in your view use your custom helper (after bringing the namespace in which the PartialHelper
static class is defined into scope in the view):
@{Html.RenderMostRecent();}
You could also use the Action
method instead of RenderAction
:
public static class PartialHelper
{
public static IHtmlString RenderMostRecent(this HtmlHelper html)
{
return html.Action("MostPopular", "Blog");
}
}
which would allow you to invoke it like this in your view:
@Html.RenderMostRecent()