Solved

App_Themes and App_Browsers. Excluding CSS file depending on browser

Posted on 2009-04-06
4
1,185 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
ID: 24096641
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
ID: 24097192
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
ID: 24097306
"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
ID: 31567125
Thanks kruegerste. That'll do the trick.

Cheers!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Foreword (May 2015) This web page has appeared at Google.  It's definitely worth considering! https://www.google.com/about/careers/students/guide-to-technical-development.html How to Know You are Making a Difference at EE In August, 2013, one …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.

919 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

19 Experts available now in Live!

Get 1:1 Help Now