1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Overriding default CSS settings

Overriding default CSS settings

4 posts, 0 answered
  1. PJulicher
    PJulicher avatar
    24 posts
    Registered:
    08 Apr 2010
    15 Apr 2010
    Link to this post
    Hi,

    I would like to apply a couple of custom CSS classes to a couple of pages within a specific Page Group. I'm thinking it might be possible to include a seperate CSS-file with the classes that need to override the default settings.

    * How can I include a CSS-file to these pages? They are based on a seperate template.
    * How can I make sure these settings are applied after the general CSS file is loaded, so that the ooverriding takes place?

    Gr, Patrick
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    15 Apr 2010
    Link to this post
    Hello PJulicher,

    You could use CssFileLink control to register a css class on a specific pages.

    Sample

    <telerik:CssFileLink ID="CssFileLink1" FileName="CommonLayout.css"
     Media="screen" runat="server"  />

    or create a control that sets the css by overriding Render method

    protected override void Render(System.Web.UI.HtmlTextWriter writer)
           {
               
                  ....
                         .....
        
                   writer.Write("type=\"text/css\" ");
                   writer.Write("rel=\"stylesheet\"");
                   writer.Write("href=\"" + url + "\"");
                   writer.Write("/>");
     
           }


    Regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. PJulicher
    PJulicher avatar
    24 posts
    Registered:
    08 Apr 2010
    15 Apr 2010
    Link to this post
    Hi Ivan,

    Thanks, but......

    This would mean I'd have to manually set the link for 80 pages in that page group. It was looking for a solution to add a css-link to my Master page for all those pages. I tried:

    <head runat="server">
        <title></title>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <link href="~/Userscripts/custom.css" rel="Stylesheet" type="text/css" />
    </head>
    <body>

    And this links the CSS, but it comes before the CSS from the THeme, and therefor has no effect.  How can I link a CSS to a Master Page being sure that it runs after the Theme's CSS?

    Gr, Patrick
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    15 Apr 2010
    Link to this post
    Hi PJulicher,

    Have you tried to add CssFileLink control in your master page?

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
4 posts, 0 answered