Solved

App_Themes and App_Browsers. Excluding CSS file depending on browser

Posted on 2009-04-06
4
1,177 Views
Last Modified: 2013-11-07
Hi,

In my ASP.NET application I am using themes. When I went to validate I came across various errors to do with non-standard CSS. For example, I was using IE's zoom and _background-image and _height.

To get around this I placed IE specific CSS "Hacks" in a separate CSS file and was hoping to be able to explicitly state which CSS file the Theme should use in code behind.

Is this possible?

Also, it appears that the Theme is recursively adding references to all CSS files in the theme folder. Is it possible to avoid this?

Many thanks,

Tomás
0
Comment
Question by:mausy
  • 2
  • 2
4 Comments
 
LVL 4

Expert Comment

by:kruegerste
Comment Utility
These "errors", are they preventing you from successfully building your application?  I use many IE specific CSS in my themes, and yes they display an error, but it doesn't stop the build process or affect anything. I just ignore them and everything is fine.  

If for some reason it does make your build fail, which I have never seen, just close the theme files when building and they won't be displayed.  VS quirk I think.
0
 
LVL 1

Author Comment

by:mausy
Comment Utility
Hi kruegerste,

no, they don't stop be building my application. However, I want my web app's CSS to validate successfully via the CSS Validator at http://jigsaw.w3.org/css-validator/ and in order for it to validate I cannot have any of the aforementioned properties like zoom etc. To that end I want to exclude the CSS file in which I have included these "IE hacks". However, .NET seems to recursively add references to all CSS files under the App_Themes\[Theme] folder...

I hope I have explained myself well enough...

T
0
 
LVL 4

Accepted Solution

by:
kruegerste earned 500 total points
Comment Utility
"To get around this I placed IE specific CSS "Hacks" in a separate CSS file and was hoping to be able to explicitly state which CSS file the Theme should use in code behind. "

In the Pre-Render method of the code-behind, you can set the Theme as such:

Private Sub TripFile_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
        'Declare current Theme to Page
        Dim AppTheme As String
        AppTheme = Application.Item("g_Theme").ToString
        Page.Theme = AppTheme
 End Sub

In this instance, I save the theme in the web.config and create it as an application variable in the global.asax. But of course, you can determine which theme to use however you like.


"Also, it appears that the Theme is recursively adding references to all CSS files in the theme folder. Is it possible to avoid this?"

No, you can't remove a css file from the Themes directory if that theme is selected as current.  Your only option is to somehow create a separate styles directory outside of the app_themes folder and reference them from there.  This would be quite easy if these "hacks" are the same, regardless of theme.  
0
 
LVL 1

Author Closing Comment

by:mausy
Comment Utility
Thanks kruegerste. That'll do the trick.

Cheers!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now