CssClass attributes

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

JezB

If a webform control is based on a cascading style sheet how can I
programatically determine the colours,etc? MyControl.CssClass will just give
me the name of the style-sheet - from this how can I access it's detailed
attributes ?
 
I'm not sure I quite understand this question

You access the individual style properties of an element with the style collectio

e.g

string sColor = textbox1.style["color"]

or

textbox1.style.add("color", "red")

The html generated on the page will be

<input type="text" style="color:red" /> etc

However, css style properties are applies by the browser, on the client. As such you cannot access these on the server.
The browser will apply the rules in the standard order of precedence, so the tag level ones emitted by asp.net, will take precedence

ht

Ada
 
It's stylesheets I'm particularly interested in. I understand that these are
applied on the browser, but I wondered whether the attributes could be
programatically accessed via client-side code (ie. javascript).

I'm not sure I quite understand this question.

You access the individual style properties of an element with the style collection

e.g.

string sColor = textbox1.style["color"];

or

textbox1.style.add("color", "red");

The html generated on the page will be

<input type="text" style="color:red" /> etc.

However, css style properties are applies by the browser, on the client.
As such you cannot access these on the server.
The browser will apply the rules in the standard order of precedence, so
the tag level ones emitted by asp.net, will take precedence.
 
Many thanks.

Eliyahu Goldin said:
On client-side document.styleSheets["style name"] gives you a reference to
the stylesheet. From there you can reference the rules:
document.styleSheets["style name"] .rules

Eliyahu

JezB said:
It's stylesheets I'm particularly interested in. I understand that these are
applied on the browser, but I wondered whether the attributes could be
programatically accessed via client-side code (ie. javascript).

I'm not sure I quite understand this question.

You access the individual style properties of an element with the
style
collection
e.g.

string sColor = textbox1.style["color"];

or

textbox1.style.add("color", "red");

The html generated on the page will be

<input type="text" style="color:red" /> etc.

However, css style properties are applies by the browser, on the
client.
As such you cannot access these on the server.
The browser will apply the rules in the standard order of precedence,
so
the tag level ones emitted by asp.net, will take precedence.
 
You can create an instance of System.Web.UI.WebControls.Style and use
methods ApplyStyle and MergeStyle to apply the instance to your control. I
don't think you can create an instance of Style out of a style in an
existent stylesheet.

Eliyahu
 
On client-side document.styleSheets["style name"] gives you a reference to
the stylesheet. From there you can reference the rules:
document.styleSheets["style name"] .rules

Eliyahu

JezB said:
It's stylesheets I'm particularly interested in. I understand that these are
applied on the browser, but I wondered whether the attributes could be
programatically accessed via client-side code (ie. javascript).

I'm not sure I quite understand this question.

You access the individual style properties of an element with the style collection

e.g.

string sColor = textbox1.style["color"];

or

textbox1.style.add("color", "red");

The html generated on the page will be

<input type="text" style="color:red" /> etc.

However, css style properties are applies by the browser, on the client.
As such you cannot access these on the server.
The browser will apply the rules in the standard order of precedence, so
the tag level ones emitted by asp.net, will take precedence.
 
Back
Top