Read From CSS

  • Thread starter Thread starter Jeronimo Bertran
  • Start date Start date
J

Jeronimo Bertran

I want to be able to programatically read the value from a css stylesheet.
For example, I have a stylesheet with the following style defined:

..dayInactive
{
background-color:#D200D2;
}


And from a C# codebehind I want to be able to obtain the value for the
background-color.

Thanks

Jeronimo Bertran
 
Jeronimo said:
I want to be able to programatically read the value from a css stylesheet.
For example, I have a stylesheet with the following style defined:

.dayInactive
{
background-color:#D200D2;
}


And from a C# codebehind I want to be able to obtain the value for the
background-color.

Thanks

Jeronimo Bertran

There is nothing built in to do this on the server side. To positively
determine the style applied to any given element is rather complicated,
including parsing the page to determine what css files are loaded, load
them and parse them all, and parse the page content to be able to
determine what styles affect the element.

If you just have a simple style like your example, and only want to read
the property from a given css file based on a single class name, you can
just read the file, look for style and extract the property.
 
Jeronimo,
CSS style declarations exist in the browser once they are loaded and are
strictly a client-side ("in the browser") construct, not subsequently
available from server-side code.

Could you be more specific about what exactly is the goal here?
Peter
 
Back
Top