Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create anchor href using Html.Helper [duplicate]

Possible Duplicate:
How to render plain HTML links in Asp.Net MVC loop?

I want to create something like this

<A href="#section2">Section Two</A>

using ASP.Net MVC's Html.Helper. How to do it?

like image 597
strike_noir Avatar asked May 07 '26 23:05

strike_noir


1 Answers

You could add your own helper for that:

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)
like image 143
Yannick Blondeau Avatar answered May 10 '26 23:05

Yannick Blondeau