473,323 Members | 1,560 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,323 software developers and data experts.

how does Style class work?

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

Similar topics

2
by: John | last post by:
The following code works OK in IE 6.0 but does not work in Netscape 7. The image does not shift when one scrolls down but stays stationary in Netscape. Please help Thank you John function...
7
by: Todd Cary | last post by:
I inherited an application where the Flyout works in Firefox but not in IE. My JavaScript background is sparse, so I am not sure how to approach the problem. Any suggestions are welcomed! The...
3
by: David | last post by:
Hi, I have 3 buttons on a asp.net page. They are exactly the same except for the name. Two of the buttons works but the third one does not respond to the clicking. Here is the code: <tr> <td...
1
by: smilecry | last post by:
I am trying to create a tree table (javascript code was adopted from online source) but the rowspan in td tag does not work well when I toggle the rows. Here is the sample code, notice the row "4"...
5
by: Ted Ngo | last post by:
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { txtSource.Focus(); frmMain.Visible = true; divWait.Visible = false; btnsubmit.Visible = true;
14
by: webEater | last post by:
I have a problem, it's not browser specific, and I don't get a solution. I have an (X)HTML document, I show you a part of it: .... <!--<div class="pad">--> <div id="eventImages"><img src=""...
2
by: gunnuk | last post by:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta...
1
by: sva0008 | last post by:
i have a auto suggest script that does not work in firefox , works great on IE. /******************************************************* AutoSuggest - a javascript automatic text input...
2
by: bips2008 | last post by:
The code seems to work fine in other browser but in IE it throws this error. This is very urgent for me and any help would be greatly appreciated For your convienence i have posted the code for the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.