When using asp.net, is it possible to modify css properties in the c# back end code in the same as Div tags? I cannot get it to work.
For example:
HTML
<div id="myDiv" runat="server" style="height:10px; color:black;" />
C#
myDiv.Style.Add("color", "white");
This works, however I am trying to do the same to a css class instead. So if I had: CSS
.myDivStyle
{
height:10px;
color:black;
}
How can I access this and change the color in c#? The only effective way I was able to find was to have two css classes and replace the class with another one such as the answer to this: Replacing css class solution
I have tried:
myDivStyle.Style.Add("color","white");
I was wondering if it is possible to include the runat="server" property directly to the css class. Thanks in advance.