andrew4582

HtmlExtentions - StyleSheetLink

Dec 21st, 2011
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. public static partial class HtmlExtentions {
  2.  
  3.     public static MvcHtmlString StyleSheetLink(this HtmlHelper html,string href,object additionalAttributes = null) {
  4.  
  5.         TagBuilder tag = new TagBuilder("link");
  6.  
  7.         tag.MergeAttribute("href",href);
  8.         tag.MergeAttribute("rel","stylesheet");
  9.         tag.MergeAttribute("type","text/css");
  10.  
  11.         if(additionalAttributes != null) {
  12.             var htmlatts = RouteValueHelper.AnonymousObjectToHtmlAttributes(additionalAttributes);
  13.             if(htmlatts != null)
  14.                 tag.MergeAttributes(htmlatts,true);
  15.         }
  16.         string tagHtml = tag.ToString(TagRenderMode.SelfClosing);
  17.         return new MvcHtmlString(tagHtml);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment