Manipulating style at runtime?

  • Thread starter Homer J. Simpson
  • Start date
H

Homer J. Simpson

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...
 
H

Homer J. Simpson

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?
 
H

Homer J. Simpson

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top