ASP.NET Actionlink with glyphicon and text with different font

后端 未结 10 955
臣服心动
臣服心动 2020-12-04 15:12

I want to present a button with @Html.ActionLink but i need to have my application font in the text.

With this code:


    @H         


        
10条回答
  •  离开以前
    2020-12-04 15:43

    Here's mine. Inspired by Andrey Burykin

    public static class BensHtmlHelpers
    {
        public static MvcHtmlString IconLink(this HtmlHelper htmlHelper, string linkText, string actionName, object routeValues, String iconName, object htmlAttributes = null)
        {
            var linkMarkup = htmlHelper.ActionLink(linkText, actionName, routeValues, htmlAttributes).ToHtmlString();
            var iconMarkup = String.Format("", iconName);
            return new MvcHtmlString(linkMarkup.Insert(linkMarkup.IndexOf(@""), iconMarkup));
        }
    }
    

提交回复
热议问题