gpt4 book ai didi

asp.net-mvc-4 - 如何使用 Html.Helper 创建 anchor href

转载 作者:行者123 更新时间:2023-12-02 06:00:04 25 4
gpt4 key购买 nike

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

我想创建这样的东西

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

使用 ASP.Net MVC 的 Html.Helper。怎么做?

最佳答案

您可以为此添加自己的助手:

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);
}
}

你可以像这样使用它:

@Html.SectionLink(section.Anchor, section.Name)

关于asp.net-mvc-4 - 如何使用 Html.Helper 创建 anchor href,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14474535/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com