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:
<pre>«/span>asp:Label
id=”lblBrowserType”
runat=”server”
IE:Text=”Hello Internet Explorer”
Mozilla:Text=”Hello Mozilla”
Safari:Text=”Hello Safari” /></pre>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.

If you enjoyed this post, please consider sharing it with others via the following Twitter or Reddit buttons. Also, feel free to checkout my egghead.io profile page for addition free and subscription lessons, collections, and courses. As always, you can reach out to me on Twitter at @elijahmanor. Thanks and have a blessed day!

Reddit