By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,886 Members | 1,107 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,886 IT Pros & Developers. It's quick & easy.

CssClass attributes

P: n/a
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 ?
Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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
Nov 18 '05 #2

P: n/a
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).

"ad**@twv.org" <an*******@discussions.microsoft.com> wrote in message
news:43**********************************@microsof t.com...
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.
hth

Adam

Nov 18 '05 #3

P: n/a
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

"JezB" <je**@somewhere.com> wrote in message
news:ew***************@TK2MSFTNGP11.phx.gbl...
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 ?

Nov 18 '05 #4

P: n/a
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[i]

Eliyahu

"JezB" <je**@somewhere.com> wrote in message
news:uy**************@TK2MSFTNGP09.phx.gbl...
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).

"ad**@twv.org" <an*******@discussions.microsoft.com> wrote in message
news:43**********************************@microsof t.com...
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.

hth

Adam


Nov 18 '05 #5

P: n/a
Many thanks.

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:eW**************@tk2msftngp13.phx.gbl...
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[i]

Eliyahu

"JezB" <je**@somewhere.com> wrote in message
news:uy**************@TK2MSFTNGP09.phx.gbl...
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).

"ad**@twv.org" <an*******@discussions.microsoft.com> wrote in message
news:43**********************************@microsof t.com...
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.

hth

Adam



Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.