Created
May 11, 2011 05:27
-
-
Save davidalpert/965971 to your computer and use it in GitHub Desktop.
HyperLink helpers that depend on FubuMVC's HtmlTags spinoff library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class HyperLinkTagHelpers | |
{ | |
public static HtmlTag HyperLink( this HtmlHelper htmlHelper, string linkText, IUrl url ) | |
{ | |
return htmlHelper.HyperLink( linkText, url, null ); | |
} | |
public static HtmlTag HyperLink( this HtmlHelper htmlHelper, string linkText, IUrl url, object htmlAttributes ) | |
{ | |
return htmlHelper.HyperLink( linkText, url.ToString(), new RouteValueDictionary( htmlAttributes ) ); | |
} | |
public static HtmlTag HyperLink( this HtmlHelper htmlHelper, string linkText, string url ) | |
{ | |
return htmlHelper.HyperLink( linkText, url, new RouteValueDictionary() ); | |
} | |
public static HtmlTag HyperLink( this HtmlHelper htmlHelper, string linkText, string url, object htmlAttributes ) | |
{ | |
return htmlHelper.HyperLink( linkText, url, new RouteValueDictionary( htmlAttributes ) ); | |
} | |
public static HtmlTag HyperLink( this HtmlHelper htmlHelper, string linkText, string url, IDictionary<string, object> htmlAttributes ) | |
{ | |
var tag = new HtmlTag( "a" ).Text( linkText ).Attr( "href", url ); | |
htmlAttributes.ToList().ForEach( attr => tag.Attr( attr.Key, attr.Value ) ); | |
return tag; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment