Styles and Cascading Style Sheets

  • Thread starter Thread starter JezB
  • Start date Start date
J

JezB

Is it possible to programatically examine and modify a page's Styles
(including Cascading Style Sheets) within the code-behind-module (eg. c#) ?

My guess is that since these are HTML elements the answer is no, since these
will only exist in the browser whereas the code-behind runs on the web
server, but I wanted verification from you experts out there (I'm new to
ASP.NET).

If the answer is no, is it possible via javascript ?

Thanks in advance.
 
for web controls : you can set CSSClass property in code behind.
as you said for HTML controls - you cant set it in code behind, but you can
set it in javascript at the client side.

control.style.className = "stylename";

Av.
 
But how can I examine and manipulate what is IN those styles ? eg. the
FONT-WEIGHT property of a style. Is this by javascript only ?
 
generally style sheets are used for putting the styles in one place. if you
want to programmatically change, its good practice to change only the name
of the style to some other style that is in the CSS file.
i am not sure of your requirement. do want to modify for server controls or
for html controls ?
Av.
 
Back
Top