tags:

views:

86

answers:

2

Hello, all. I'm using conditional commenting in IE to fix some CSS problem that i'm having with IE7.

I have a all.css file that work on firefox and ie7 with some execptions that will only fix the IE7 css problem. I put my fix on all_iefixes.css both files is in App_Themes/Default/ folder.

I use have a master page (Default.master) that all my pages inherited. On some page that is inside another folder, for example, localhost/myapp/blah1/blah.aspx will not get the all_iefixes.css in the App_Themes/Default folder If i change the

<!--[if IE]><style type="text/css">@import "all_iefixes.css";</style><![endif]-->

to

<!--[if IE]><style type="text/css">@import "./../App_Themes/Default/all_iefixes.css";</style><![endif]-->

then it will work for the page inside the blah1 folder but it will break other page that doesn't live inside blah1 folder.

I think i can create several master page and depend on where i want to put my aspx pages to live then i can adjust the link but i think this is a rather "stupid" fix (?). Is there an elegant way to do this.

Jack

+3  A: 

You should avoid using relative paths in your master pages unless you can generate it with code:

You can try using server tags to resolve the path, but this is not always possible (for instance, if youre manipulating the control tree in code)

@import "<% this.ResolveUrl("~/App_Themes/Default/all_iefixes.css") %>";
BC
Do you mean to put that code in the conditional comment?
Jack
Yes, within the conditional comment, OR print the entire conditional comment with the ResolveUrl method call entirely from code.
BC
A: 

+1 from the ablove. However, I'd rather use browser files in ASP.NET.

Jason N. Gaylord
Hello, do you have a tutorial link regarding on how to use browser file to determine which CSS file to load?
Jack