How to create href binding using Html.Helper
Possible duplicate:
How to render simple HTML links in an Asp.Net MVC loop?
I want to create something like this
<A href="#section2">Section Two</A>
using ASP.Net MVC Html.Helper. How to do it?
+3
source to share
1 answer
You can add your own helper to this:
public static class HtmlHelpers
{
public static string SectionLink(this HtmlHelper html, string URL, string display)
{
return String.Format("<a href=\"{0}\">{1}</a>", URL, display);
}
}
And you use it like this:
@Html.SectionLink(section.Anchor, section.Name)
+5
source to share