473,386 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

CssClass attributes

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
5 2509
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Steve Kallal | last post by:
I have a DataGrid with an EditCommandColumn column set to a type of PushButton. I want to set set CssClass on these buttons and cannot without using code-behind code on the ItemDataBound event. The...
1
by: Fernando Lopes | last post by:
Hi. I need to change de css of an asp.net textbox control. So, on mouseover event, the class will be one, and on mouseout event it will be another. Something like: ...
6
by: msuk | last post by:
All, I have a ASP.NET/C# webform which contains a Webform button that has a CssClass applied to give it a special effect. Now the same webform has a filefield control but the browse button is...
6
by: tshad | last post by:
Are Validators able to use CSSClass? I have the following: <asp:RegularExpressionValidator ControlToValidate="txtEmail" CssClass="errorMessage" Text = "Invalid Email Address!"...
1
by: Joey | last post by:
I have noticed that the grid's Select linkbutton is rendered as an HTML anchor tag on the client. I would really like to be able to get a "class" attribute in it, either through CssClass on the...
0
by: Daves | last post by:
If I put the following in the skin definition nothing happens, the links are still not-black (all other attributes are there) ?? <asp:GridView SkinID="Test" > <Columns> <asp:HyperLinkField...
1
by: WebBuilder451 | last post by:
I have htmlcontrols.htmltablecells on a page. I can find the Tablecells ok and can set some of the attributes, but not the cssClass. How is this done? i can for asp controls, but not for these. ...
6
by: Larry Bud | last post by:
Can it be done? I have a table, and in the <TDI have <Td runat="server" id="mycell" class="myclass"></td> In the code behind, I can access mycell.style, but there is no mycell.CssClass...
1
by: Jonathan Wood | last post by:
Greetings, On a GridView control, I want to show alternating colors. But instead of alternating on each row, I want to alternate each group. So several items would be one color and the next...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.