Read a CSS File

A

Alphonse Giambrone

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
 
V

Victor Garcia Aprea [MVP]

Hi Alphonse,

In ASP.NET there is no built-in support for parsing CSS files, so you will
need to write your own parser.
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?
 
A

Alphonse Giambrone

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
 
S

Steven Cheng[MSFT]

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
 
A

Alphonse Giambrone

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.
 

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

No members online now.

Forum statistics

Threads
473,890
Messages
2,569,971
Members
46,306
Latest member
MarcMcEach

Latest Threads

Top