Monday, September 11, 2006

Device Filters

As I mentioned in my CSS Adapters Beta 2 entry, the asp:Menu control does not work well with Safari. As I was trying to research how to make the control compatible ( before I knew about the CSS Adapaters ), I searched Google for workarounds and found the article Using Device Filters ( and making Menu work with Safari ). This was a new feature in ASP.NET 2.0 that I had never heard before. Using device filters you can prepend a browser type to your aspx tag attributes to change the behavior of the tag.

For example you can do the following:
<asp:Label 
id="lblBrowserType"
runat="server"
IE:Text="Hello Internet Explorer"
Mozilla:Text="Hello Mozilla"
Safari:Text="Hello Safari" />
Althought probably not useful, when viewed the above code will display "Hello Internet Explorer" if you viewed the page with IE, "Hello Mozilla" if you viewed the page with Firefox, and etc...

The device filters use the same Browser Definition File Schema information that I shared in my HttpBrowserCapabilities entry.

Unfortuantely, I wasn't able to get the menu to look like I wanted in Safari using device filters, but it did enlighten me to the new feature.

Saturday, September 09, 2006

CSS Adapaters Beta 2

For those of you who would like more control of your HTML output from ASP.NET 2.0, then check out the newly updated CSS Adapters Beta 2.

At one point I looked into using "CSS Adapters Beta 1" because the native asp:Menu HTML output does not work well with all browsers ( mainly Safari ). However, my direction was altered in another direction that didn't need the asp:Menu control, so Safari compatibility with the menu was no longer an issue.

Anyway, I know there are some hardcore CSS gurus who will do anything they can to not use tables for non-tabular data. If that describes you, or if you'd just like a little more control of your HTML output, then check out the CSS Adapters Beta 2.

Thursday, September 07, 2006

HttpBrowserCapabilities

The current project I am working on involves a website that is external facing. Since I am using CSS and JavaScript in ASP.NET 2.0 older browsers may not behave as expected. Therefore, I implemented White, Black, and Gray browser lists.

Initially, I used a JavaScript Browser Sniffer Library written by Pau Garcia i Quiles, but then I became aware of the HttpBrowserCompatibilites class in .NET!

I just finished rewritting the lists using .NET's Browser object ( located off the Request object ). If you are interested in knowing how .NET figures out all this information check out the Browser Definition File Schema. You can find all of the browser definitions on your machine at "%SystemRoot%\Microsoft.NET\Framework\version\CONFIG\Browsers". Its very interesting to look through the files and see what information .NET uses to determine your browser information.