Solved

App_Themes and App_Browsers. Excluding CSS file depending on browser

Posted on 2009-04-06
4
1,212 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
c#, case, if 4 37
Excel Web Add-in Where is Visual Basic used 9 83
.Net remove carriage returns, line feeds and tabbs 5 36
Access-Control-Allow-Origin 4 45
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
This video teaches users how to migrate an existing Wordpress website to a new domain.
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.

739 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