CssClass attributes

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 ?
 
G

Guest

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
 
J

JezB

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.
 
J

JezB

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.
 
E

Eliyahu Goldin

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
 
E

Eliyahu Goldin

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top