Manipulating style at runtime?

Discussion in 'ASP .Net' started by Homer J. Simpson, Aug 9, 2007.

  1. Hi all,

    I'm trying to manipulate a calendar header's style programmatically at
    runtime. This works:

    <asp:Calendar id="clndr" [...]>

    Page_Load()
    {
    clndr.TitleStyle.BackColor = System.Drawing.Color.FromArgb( 255, 0, 0 );
    }

    This, however, doesn't:

    Page_Load()
    {
    clndr.TitleStyle.CssClass.Insert( 0, "background-color: #FF0000;" );
    }

    Am I misinterpreting the intent behind CssClass.Insert()?


    I know I could stick with TitleStyle.BackColor, but what I'm ultimately
    trying to do is specify an attribute that isn't recognized as a member of
    clndr.TitleStyle.CssClass. I'm just experimenting for now. This
    calendar--being ported from classic ASP--used to have the following style:

    ..title
    {
    filter:
    progid:DXImageTransform.Microsoft.Gradient(startColorStr='#000000',
    endColorStr='#D4D0C8', gradientType='1');
    }

    Obviously, "filter" isn't a member of clndr.TitleStyle (so I couldn't change
    its startColorStr or endColorStr values), so I thought I could get around
    that with something like:

    string strFilter = "filter:
    progid:DXImageTransform.Microsoft.Gradient(startColorStr='#000000',
    endColorStr='#D4D0C8', gradientType='1');";
    clndr.TitleStyle.CssClass.Insert( 0, strFilter ).

    However my test above with the background-color attribute tells me I'm doing
    something wrong. If I could get *that* to work first, then I'll try to get
    the filter attribute to work next...
     
    Homer J. Simpson, Aug 9, 2007
    #1
    1. Advertising

  2. DOH!

    I can't believe the stupidity.

    CssClass.Insert() inserts some characters in a string. Namely, the class
    name.

    Okay, well...anyone wants to take a shot at what I was trying to accomplish
    in my original message?
     
    Homer J. Simpson, Aug 9, 2007
    #2
    1. Advertising

  3. Nobody?

    Okay, let me rephrase the question in a more generic way:

    How do I dynamically change (or add) a value for a css attribute, when that
    particular attribute doesn't have a corresponding member in code?

    In other words, I want code to add the following css attribute:

    filter: progid:DXImageTransform.Microsoft.Gradient(startColorStr='#000000',
    endColorStr='#D4D0C8', gradientType='1');

    ....in my Page_Load() event. How do I get to the class and add this string
    to it?
     
    Homer J. Simpson, Aug 10, 2007
    #3
    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. Timo Nentwig

    manipulating classes during runtime

    Timo Nentwig, Jul 14, 2003, in forum: Java
    Replies:
    2
    Views:
    401
    Sandip Chitale
    Jul 15, 2003
  2. Hal Vaughan
    Replies:
    11
    Views:
    1,172
    Gordon Beaton
    May 22, 2006
  3. Ken Varn
    Replies:
    0
    Views:
    504
    Ken Varn
    Apr 26, 2004
  4. KK

    manipulating datagrid at runtime

    KK, Jan 11, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    135
    Alvin Bruney
    Jan 11, 2004
  5. Dag Sunde
    Replies:
    2
    Views:
    151
    Dag Sunde
    Dec 20, 2006
Loading...

Share This Page