Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 2 of 2

Thread: Allow customers to change link color seasonally

  1. #1
    philbonsai is offline Junior Member
    Join Date
    Nov 2010
    Posts
    5

    Default Allow customers to change link color seasonally

    Hello

    I am trying to provide the ability for my customer to change the text color easily. I created a new appconfig that accepts the name of the css file which contains the hex code for the color. Then, I tried to call this appconfig value in the masterpage in a <link>. This is the code:

    <link href="../../App_Templates/Skin_1/css/<% Tokens:AppConfig2, SiteDisplay.seasonalText %>.css" type="text/css" rel="stylesheet" runat="server" />

    All four css files with the color would be in the Skin_1/css directory. So if the value of "seasonalText" is "blue" then the above should in turn get blue.css. I was advised however, that skin tokens within links wouldn't work -- that I'd have to use an AppConfig to determine which CSS sheet to use for the entire skin, not within an individual link. Can anyone provide clarification? Or advice on some other way to allow my customer to change the color easily? One work-around is to create four different skins, each containing the different seasonal colors and then my customer can just choose the skin, but that seem like a poor solution since we'll be duplicating many times a lot of files. Thanks for help in advance!

    Phil

  2. #2
    philbonsai is offline Junior Member
    Join Date
    Nov 2010
    Posts
    5

    Default

    I figured this out finally. Had to use StringResource instead of an AppConfig. Here it is:

    Code:
    <asp:Literal ID="textColor" runat="server" Text="<%$ Tokens:StringResource, seasonalTextColor %> Visible="false"" />
    
    <script runat="server">
            void Page_Load(object sender, EventArgs e)
            {
                var testColor = textColor.Text;
                HtmlLink css = new HtmlLink();
                css.Href = "css/" + testColor + ".css";
                css.Attributes["rel"] = "stylesheet";
                css.Attributes["type"] = "text/css";
                css.Attributes["media"] = "all";
                Page.Header.Controls.Add(css);
            }    
        </script>
    Hope this helps. Cheers!