using System; using System.Data; using System.Collections; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using CMS.GlobalHelper; using CMS.PortalControls; public partial class CMSWebParts_General_cssstylesheet : CMSAbstractWebPart { #region "Public properties" /// /// Gets or sets path to the stylesheet file. /// public string FilePath { get { return ValidationHelper.GetString(GetValue("FilePath"), ""); } set { SetValue("FilePath", value); } } /// /// Gets or sets the media type. /// public string Media { get { return ValidationHelper.GetString(GetValue("Media"), "screen"); } set { SetValue("Media", value); } } #endregion #region "Methods" /// /// Content loaded event handler. /// public override void OnContentLoaded() { base.OnContentLoaded(); SetupControl(); } /// /// Initializes the control properties. /// protected void SetupControl() { } /// /// PreRender event handler. /// /// EventArgs protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); if (!StopProcessing) { // Add link to page header string url = CSSHelper.GetPhysicalCSSUrl(FilePath); string link = CSSHelper.GetCSSFileLink(url, Media); LiteralControl ltlCss = new LiteralControl(link); ltlCss.EnableViewState = false; Page.Header.Controls.Add(ltlCss); } } #endregion }