Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

Manipulating style at runtime?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Homer J. Simpson - 09 Aug 2007 18:59 GMT
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 - 09 Aug 2007 19:18 GMT
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 - 10 Aug 2007 14:50 GMT
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?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.