Use it as follow:
@StyleSheet("default")

Here the extension method:
public static IHtmlString StyleSheet(this UrlHelper urlHelper, string styleSheet)
{
	var host = HttpContext.Current.Request.Url.Host;

	host = host.Substring(0, host.LastIndexOf('.'));

	var url = urlHelper.Canonical(string.Format("~/Content/Themes/{0}/{1}.css", host, styleSheet));

	var tagBuilder = new TagBuilder("link");

	tagBuilder.MergeAttribute("rel", "stylesheet");
	tagBuilder.MergeAttribute("type", "text/css");
	tagBuilder.MergeAttribute("href", url);

	return new HtmlString(tagBuilder.ToString(TagRenderMode.SelfClosing));
}

Last edited Mar 16, 2011 at 6:15 PM by teoarch, version 1

Comments

No comments yet.