Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nirav Panchal 7 posts 76 karma points
    Nov 22, 2017 @ 09:00
    Nirav Panchal
    0

    How to apply Dynamic CSS in Umbraco page ?

    [‎22-‎11-‎2017 14:20] Nirav Panchal: Hi,

    I have created single web page in umbraco. I want to apply dynamic css on the page.

    Suppose we have 3 College :

    1. College A
    2. College B
    3. College C

    College A, College B, College C : having their own css.

    So according to the selection it will apply the css.

    So how could I do it with my project ?

    Can anyone help me ? now ?

  • Steve Morgan 1349 posts 4458 karma points c-trib
    Nov 22, 2017 @ 09:16
    Steve Morgan
    0

    Hi,

    Do you want CSS on certain pages or across the entire college site?

    I think you mean want the entire site to have the css but use the same master template? I would add a drop down "CssSelection" at the root homepage node - here I've called the values Css1 .. Css3 but you should name them the same as the corresponding CSS files for the colleges.

    Add a dropdown

    In your template you can "get" this node and check the value to decide which CSS file reference to output. E.g.

       @{
            var home = Model.Content.AncestorOrSelf("1");
            var css = home.GetPropertyValue<string>("cssSelection");
            string cssFileLocation = "/css/" + css + ".css";
            <link rel="stylesheet" type="text/css" href="@cssFileLocation" />
        }
    

    HTH

    Steve

  • Nirav Panchal 7 posts 76 karma points
    Nov 22, 2017 @ 13:05
    Nirav Panchal
    0

    Thank you Steve

Please Sign in or register to post replies

Write your reply to:

Draft