Where in the page lifecycle do stylesheets get loaded?

3 posts, 0 answers
  1. LeBear
    LeBear avatar
    233 posts
    Member since:
    May 2006

    Posted 12 Sep 2009 Link to this post


    I've created a site management system that has a base theme that is loaded via the pages directive in the web.config:
    <pages ... styleSheetTheme="Base">...</pages> 

    Then, to customize the look and feel for an individual site, I reference a theme in the Page_PreInit method:
    Me.Theme = "SiteTheme" 

    This works great.  Anything defined in the Base theme gives you a standard appearance for any given component of the system.  However, if you want to override the look and feel for an individual site, you can declare the same CSS definitions inside the Site Theme.

    If I were to use the StyleSheet Manager to combine CSS files, when would they get loaded.  My goal would be to manage all of the Base theme information with the StyleSheet Manager and still allow them to be overridden by the Site Theme.

    Another side question:  Would the StyleSheet Manager help beyond just combining all of the CSS files in my Base theme into a single CSS file?

    Thank you.
  2. Atanas Korchev
    Atanas Korchev avatar
    8462 posts

    Posted 15 Sep 2009 Link to this post

    Hi Barry,

    A control registers with RadStyleSheetManager during its PreRender event if and only if it is using any of the built-in skins. RadStyleSheetManager currently combines only embedded CSS files. If you are using a custom skin you can check this help topic how to embed it.

    All the best,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft R3 2016 release webinar banner
  4. LeBear
    LeBear avatar
    233 posts
    Member since:
    May 2006

    Posted 15 Sep 2009 Link to this post

    Hello Albert:

    You didn't answer my question, but in retrospect, I realize the answer is pretty simple simply by looking at the generated HTML in a page within the application.

    To answer my own question:

    If I have a theme specified as the styleSheetTheme within the web.config, all CSS files for that theme appear in the head of the HTML output first.  If I then have a theme specified for the pages (which I set in the Page_PreInit method of all pages), the CSS files for that theme appear next, which allows them to override CSS settings in the styleSheetTheme.  Finally, the last CSS file referenced in sequence is the generated resource created by the StyleSheetManager.

    As such, if a single CSS class appears in all three places, the one placed into the StyleSheetManager resource will override the others.

    For my purposes, I don't want to place any CSS information from the base theme (specified as the styleSheetTheme) into the StyleSheetManager, as I design it so that those classes can be overridden by the site-specified theme in the Page_PreInit method.

Back to Top