You need to sign in to do that
Don't have an account?

Passing value from controller to css in salesforce
Hi All,
i have a custom page in that i want to display data in table. In that table, some data display with some color and it comes from controller.
in VF page, i put it like this
But now i want to use style class at <td>. and that color needs to come from controller.
How should i acheave this problem using CSS. Because need CSS file that i put in static Resources.
Please help me any one using CSS only.
I appriciate your response.
Thank you.
Rakesh.S
i have a custom page in that i want to display data in table. In that table, some data display with some color and it comes from controller.
in VF page, i put it like this
<td style="background-color:{!w.EnglishColor}">SocialColor came from controller. its working fine.
But now i want to use style class at <td>. and that color needs to come from controller.
How should i acheave this problem using CSS. Because need CSS file that i put in static Resources.
Please help me any one using CSS only.
I appriciate your response.
Thank you.
Rakesh.S
You can define a style for a particular class and define this style in your CSS file like this
And than assign the class to your <td> tag.
w.EnglishColor is should be hold the name of class for td tag.
-Thanks
Ashlekh Gera
its not working. in style class, i want to define only backgroud color that is {!w.Englishcolor} and cames from controller. how can i assign this styleclass to <td> tag. <td styleClass="{!w.EnglishColor}">
Please anyone explain with some more explanation.
You can define a style for a particular class and define this style in your CSS file like this
syntax: css class
<style>
.classname
{
define the style here
}
</style>
I think this documentation is worth reading through for a better understanding of adding the css class to controller
(http://salesforce.stackexchange.com/questions/25837/visualforce-adding-css-class-from-controller)
Thanks,
B.karunakar
https://lovesalesforceyes.blogspot.com/2020/07/two-ways-to-set-dynamic-style-in.html