I wrote custom HTML helper and it used @Html.ActionLink
which obviously won't work because the code is in App_Code. Then I referred this link
Using MVC HtmlHelper extensions from Razor declarative views
and changed my helper to this:
@inherits MVCWebApp.Helpers.CustomHelperPage
@using System.Web.Mvc.Html
@using System.Web.Mvc
@helper GetPager(string action, string controller, int NoOfPagesToGenerate)
{
//implementation
}
and this is the CustomPageHelper:
using System.Web.WebPages;
using System.Web.Mvc;
namespace MVCWebApp.Helpers
{
public class CustomHelperPage : System.Web.WebPages.HelperPage
{
public static new HtmlHelper<object> Html
{
get { return ((System.Web.Mvc.WebViewPage)WebPageContext.Current.Page).Html; }
}
}
}
Can anybody tell me what is the above code doing and how is it working?