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

how does Style class work?

P: n/a
I have create Style class instance and set up properties like this:

Style st = new Style();
st.BackColor = Color.Black;
st.BorderColor = Color.White;
st.BorderStyle = BorderStyle.Solid;
st.BorderWidth = new Unit(1, UnitType.Pixel);

string styleStr = string.format("this.style.cssText='{0}', st.ToString());

cell.Attributes.Add("onmouseover", styleStr);
But st.ToString() seems to always return "" (string.empty). I want to return something like 'background-Color=Black; ... " text.

How the Style() class work and how i can do what i want?
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
I see you want to apply the style on client side. The easiest way of doing
this is like this:

1. Attach the style "MyStyle" to your page, either in the page header or in
a separate file.
2. cell.Attributes.Add("onmouseover", "className='MyStyle'");

Eliyahu

and then change className property on the client side.
"terrorix" <te******@centrum.sk> wrote in message
news:OO**************@tk2msftngp13.phx.gbl...
I have create Style class instance and set up properties like this:

Style st = new Style();
st.BackColor = Color.Black;
st.BorderColor = Color.White;
st.BorderStyle = BorderStyle.Solid;
st.BorderWidth = new Unit(1, UnitType.Pixel);

string styleStr = string.format("this.style.cssText='{0}', st.ToString());

cell.Attributes.Add("onmouseover", styleStr);
But st.ToString() seems to always return "" (string.empty). I want to return something like 'background-Color=Black; ... " text.
How the Style() class work and how i can do what i want?

Nov 18 '05 #2

P: n/a
Eliyahu Goldin wrote:
I see you want to apply the style on client side. The easiest way of doing
this is like this:

1. Attach the style "MyStyle" to your page, either in the page header or in
a separate file.
2. cell.Attributes.Add("onmouseover", "className='MyStyle'");

Eliyahu

and then change className property on the client side.
"terrorix" <te******@centrum.sk> wrote in message
news:OO**************@tk2msftngp13.phx.gbl...
I have create Style class instance and set up properties like this:

Style st = new Style();
st.BackColor = Color.Black;
st.BorderColor = Color.White;
st.BorderStyle = BorderStyle.Solid;
st.BorderWidth = new Unit(1, UnitType.Pixel);

string styleStr = string.format("this.style.cssText='{0}', st.ToString());

cell.Attributes.Add("onmouseover", styleStr);
But st.ToString() seems to always return "" (string.empty). I want to

return something like 'background-Color=Black; ... " text.

How the Style() class work and how i can do what i want?

I know i can do this like you wrote. But i creating web custom control. I have properties like:
HotTrack_BackColor
HotTrack_BorderColor
HotTrack_BorderStyle
HotTrack_BorderWidth

and i want to setup these custom properties to control as "this.style.cssText='...'".

Anyway how can i use Style class manually ?
Nov 18 '05 #3

P: n/a
Doesn't look to me like the Style class is good for your task. It is not
intended for this sort of use. Just go through all your style properties and
make a style string out of style attributes like

String.Format("background-color:{0}", HotTrack_BackColor.ToString());

Eliyahu

"terrorix" <te******@centrum.sk> wrote in message
news:u%****************@TK2MSFTNGP12.phx.gbl...
Eliyahu Goldin wrote:
I see you want to apply the style on client side. The easiest way of doing this is like this:

1. Attach the style "MyStyle" to your page, either in the page header or in a separate file.
2. cell.Attributes.Add("onmouseover", "className='MyStyle'");

Eliyahu

and then change className property on the client side.
"terrorix" <te******@centrum.sk> wrote in message
news:OO**************@tk2msftngp13.phx.gbl...
I have create Style class instance and set up properties like this:

Style st = new Style();
st.BackColor = Color.Black;
st.BorderColor = Color.White;
st.BorderStyle = BorderStyle.Solid;
st.BorderWidth = new Unit(1, UnitType.Pixel);

string styleStr = string.format("this.style.cssText='{0}', st.ToString());
cell.Attributes.Add("onmouseover", styleStr);
But st.ToString() seems to always return "" (string.empty). I want to return something like 'background-Color=Black; ... " text.

How the Style() class work and how i can do what i want?

I know i can do this like you wrote. But i creating web custom control. I

have properties like: HotTrack_BackColor
HotTrack_BorderColor
HotTrack_BorderStyle
HotTrack_BorderWidth

and i want to setup these custom properties to control as "this.style.cssText='...'".
Anyway how can i use Style class manually ?

Nov 18 '05 #4

P: n/a
Eliyahu Goldin wrote:
Doesn't look to me like the Style class is good for your task. It is not
intended for this sort of use. Just go through all your style properties and
make a style string out of style attributes like

String.Format("background-color:{0}", HotTrack_BackColor.ToString());

Eliyahu

I using this technique but i want know if it is another way to the this, more clear.

thanx again.
Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.