how does Style class work?

Discussion in 'ASP .Net' started by terrorix, May 12, 2004.

  1. terrorix

    terrorix Guest

    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?
     
    terrorix, May 12, 2004
    #1
    1. Advertising

  2. terrorix

    terrorix Guest

    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" <> wrote in message
    > news:...
    > > 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 ?
     
    terrorix, May 12, 2004
    #2
    1. Advertising

  3. terrorix

    terrorix Guest

    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.
     
    terrorix, May 12, 2004
    #3
  4. 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" <> wrote in message
    news:...
    > 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?
     
    Eliyahu Goldin, May 12, 2004
    #4
  5. 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" <> wrote in message
    news:u%...
    > 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" <> wrote in message
    > > news:...
    > > > 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 ?
     
    Eliyahu Goldin, May 12, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. E11
    Replies:
    1
    Views:
    4,793
    Thomas Weidenfeller
    Oct 12, 2005
  2. Joshua Beall
    Replies:
    14
    Views:
    13,498
    C A Upsdell
    Oct 30, 2003
  3. dlo_olb
    Replies:
    2
    Views:
    2,311
    Fredrik Lundh
    Jun 25, 2003
  4. Ken Varn
    Replies:
    0
    Views:
    477
    Ken Varn
    Apr 26, 2004
  5. Jayden
    Replies:
    9
    Views:
    296
    alex23
    Sep 27, 2012
Loading...

Share This Page