2

When I use the build in Html Helpers, I can simply write the following.

@Html.Actionlink(bla)

But when I write my own Html Helpers, I need to block the encoding by wrapping it in a MvcHtmlString

@MvcHtmlString.Create(Html.CustomPager(bla))

Is there anything I can do in the extension method so that I don't have to worry about "not" encoding it?

Chase Florell
  • 46,378
  • 57
  • 186
  • 376

1 Answers1

5

yes, you can make the helper return a MvcHtmlString - i.e:

public static MvcHtmlString Css(this HtmlHelper html, string path)
{
    return MvcHtmlString.Create(/* some code*/);
}

rather than:

public static string Css(this HtmlHelper html, string path)
{
    return (/* some code*/);
}

i don't know the razor requirements, so this is a blind stab in the dark answer perhaps..

jim tollan
  • 22,305
  • 4
  • 49
  • 63