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.

No comments:

Post a Comment