/// <summary> /// Registers a CSS file reference to be aggregated in a layout later, with a call to <see cref="RenderStylesheets"/>. /// This method is a shortcut to <see cref="RegisterReference"/>. /// </summary> public static void Stylesheet(this HtmlHelper html, CssMediaType media, params string[] styleUrls) { if (styleUrls == null) { return; } html.RegisterReference(StyleCatalogKey, styleUrls.Distinct().ToDictionary(u => u, u => new HelperResult(w => w.Write("<link rel=\"stylesheet\" type=\"text/css\" media=\"{1}\" href=\"{0}\" />", u.ToLower(), media)))); }
public static MvcHtmlString CssInclude(this HtmlHelper htmlHelper, string filename, CssMediaType mediaType = CssMediaType.All) { var helper = new UrlHelper(htmlHelper.ViewContext.RequestContext); string filepath = filename.StartsWith("~") ? filename : "~/content/css/" + filename; string url = helper.Content(filepath); return (MvcHtmlString.Create( string.Format("<link href=\"{0}\" rel=\"stylesheet\" type=\"text/css\" media=\"{1}\" />", url.ToLower(), mediaType.ToString().ToLower()))); }
public CssInclude(IClientDependencyFile file, CssMediaType mediaType) : base(file) { DependencyType = ClientDependencyType.Css; CssMedia = mediaType; }
public static void Stylesheet(this WebViewPage page, CssMediaType media, params string[] resourceNames) { page.Html.Stylesheet(media, resourceNames.Select(rn => page.Resource(rn)).ToArray()); }