Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

App_Themes and App_Browsers. Excluding CSS file depending on browser

Posted on 2009-04-06
4
Medium Priority
?
1,247 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A Change in PHP Behavior with Session Write Short Circuit (http://php.net/manual/en/book.session.php#116217) (Winter 2014)** With the release of PHP 5.6 the session handler changed in a way that many think should be considered a bug.  See the note …
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
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 custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

721 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