0

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?

halfer
  • 19,824
  • 17
  • 99
  • 186
TCM
  • 16,780
  • 43
  • 156
  • 254

1 Answers1

0

Does this help?

HtmlHelper _html = new HtmlHelper(
    new ViewContext(ControllerContext
        , new WebFormView(ControllerContext, "dummy")
        , new ViewDataDictionary()
        , new TempDataDictionary()
        , writer)
    , new ViewPage());
Valamas
  • 24,169
  • 25
  • 107
  • 177