I want to use the ViewPage/HtmlHelper class in the System.Web.Mvc namespace in a seperate project. I imported the relevant libraries and then tried this:
using System.Web.Mvc;
using System.Web.Mvc.Resources;
using System.Web.Mvc.Html;
public static class Display
{
public static string CheckBox()
{
ViewPage viewPage = new ViewPage();
return viewPage.Html.CheckBox("Test");
}
}
Which I call like this in another class that includes my display class:
string Checkbox = Display.CheckBox():
This compiles just fine, however when I run it I get:
System.NullReferenceException: Object reference not set to an instance of an object.
I simply want to use the HtmlHelper's extension methods as is, e.g: page.Html.ActionLink(), page.Html.Radionbutton() etc. How can I resolve this problem?