Skip to content

Instantly share code, notes, and snippets.

@martinnormark
Created September 5, 2012 14:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinnormark/3637594 to your computer and use it in GitHub Desktop.
Save martinnormark/3637594 to your computer and use it in GitHub Desktop.
Use HtmlHelper from MVC Controller
public string Test()
{
TextWriter tw = TextWriter.Null;
HtmlHelper<TestViewModel> htmlHelper = new HtmlHelper<TestViewModel>(new ViewContext(ControllerContext,
new RazorView(ControllerContext, "asd", "sdsd", false, null),
new ViewDataDictionary(),
new TempDataDictionary(), tw), new ViewPage());
return htmlHelper.TextBoxFor(m => m.Name).ToString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment