Groups | Blog | Home
all groups > asp.net building controls > june 2004 >

asp.net building controls : Read a CSS File


Alphonse Giambrone
6/25/2004 8:07:19 PM
Using vb.net.
Can anyone provide some insight or examples of reading a css file.
I want to be able to read the name/value pairs for some classes.
My asp.net app is using IE WebControls TabStrips which don't support css
from a file. That makes is a chore to change all the tab styles when needed.
I finally figured out how to set the tab styles via code, so that does
simplify it some. It would be even better if I could read the styles from a
css file so I don't need to change code to change the tab styles.

TIA

--

Alphonse Giambrone
Email: a-giam at customdatasolutions dot us


Victor Garcia Aprea [MVP]
6/25/2004 9:40:07 PM
Hi Alphonse,

In ASP.NET there is no built-in support for parsing CSS files, so you will
need to write your own parser.

[quoted text, click to view]
Mmm... what exactly do you mean by this? I'm not much familiar with the
TabStrip control but I'm guessing it derives directly or indirectly from
System.Web.UI.WebControls.WebControl which has a CssClass property where you
can specify the css class to use. Isn't this useful to you?

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx


[quoted text, click to view]

Alphonse Giambrone
6/26/2004 8:37:49 AM
Thanks for the response Victor.
Yes, the tabstrip has a css property, but I don't know what it affects and
can't find any docs on it.
What I need to set are the various tab and separator styles which can be set
in the html using standard style syntax.
Each is an attribute (TabDefaultStyle, TabSelectedStyle, TabHoverStyle,
SepDefaultStyle) and are of type Microsoft.Web.UI.WebControls.CssCollection.

http://msdn.microsoft.com/library/default.asp?url=/workshop/webcontrols/overview/tabstrip.asp

To set via code one must build the attribute with the usual
collection.Add(key,value) syntax.
I have tried various arrangements in a css file, but nothing I tried worked.
Some of my trials include:

mytabstyle.TabDefaultStyle
{
background-image:url(../images/myimage.gif);
}

TabDefaultStyle mytabstyle
{
background-image:url(../images/myimage.gif);
}
..mytabstyle TabDefaultStyle
{
background-image:url(../images/myimage.gif);
}

It would be easier to extract the styles from an xml file, but by using a
css file, I can use the stylebuilder.

If you have any other suggestions, I am open.

--

Alphonse Giambrone
Email: a-giam at customdatasolutions dot us


[quoted text, click to view]

Alphonse Giambrone
6/28/2004 7:45:54 AM
Thanks Steven, I already managed to parse out the classes I need and apply
to the tabstrips, but will certainly check out those links for more ideas.

--

Alphonse Giambrone
Email: a-giam at customdatasolutions dot us


[quoted text, click to view]

v-schang NO[at]SPAM online.microsoft.com
6/28/2004 8:32:09 AM
Hi Alphonse,

As Victor has mentioned that the .net framework hasn't provided buildin
support for processing css file or the css format data. If we want to
programmatically parse it, we have to define our own class library. In
addition, here are some cetain resources I've found on the web which may be
helpful to you:

#Css parser
http://www.programmersheaven.com/zone15/cat1232/30461.htm

#CSS Custom Provider To extend Web Control's Property Window
http://www.codeproject.com/aspnet/RaoCSSProvider.asp

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

AddThis Social Bookmark Button