[SalesForce] posting AMPscript variables into a remote css style sheet

We want a div on an ExactTarget landing page to reflect a background color defined in a Data Extension. My thought process includes setting a text field with the color code and then using an AMPscript variable in the style sheet such as:

{... background-color: %%=v(@clientColorPref)=%%; ...}

This doesn't appear to be working so while we can simply create the style inline I am curious to know if it simply doesn't work to post AMPscript variables in a .css file (which is also built as a an ExactTarget landing page) or if something special needs to be done to see or review it.

I was certain to post the variable on the html page PRIOR to the link to the style sheet knowing that the order of calls would be critical. As stated I am obtaining a similar result using an inline style on that element to keep all of the code within the HTML file but would prefer to maintain styling of DOM elements on the remote page.

Best Answer

What you are trying to do is certainly possible as I have done something similar.

IF that is your exact code, then the problem is you are missing an "@" on your variable, should read:

{... background-color: %%=v(@clientColorPref)=%%; ...}

The way to do it would be:

  1. Create an ampscript block at the top of the page.

  2. Do your DE lookup.

  3. Set your AMPscript variable to the desired field.

  4. Use the "v()" operation in your actual script.

Hope this helps.