Skip to content

Instantly share code, notes, and snippets.

@tathamoddie
Created July 27, 2010 01:17
Show Gist options
  • Save tathamoddie/491560 to your computer and use it in GitHub Desktop.
Save tathamoddie/491560 to your computer and use it in GitHub Desktop.
public static void RegisterStyleSheets(this Page page, IEnumerable<string> appRelativePaths)
{
if (page == null) throw new ArgumentNullException("page");
if (page.Header == null) throw new ArgumentException("Page header is unavailable.", "page");
var links = appRelativePaths
.Select(page.ResolveClientUrl)
.Select(p =>
{
var link = new HtmlLink { Href = p };
link.Attributes.Add("rel", "stylesheet");
link.Attributes.Add("type", "text/stylesheet");
return link;
});
foreach(var link in links)
page.Header.Controls.Add(links);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment