by

Rendering ASP.NET controls in Mozilla, Opera, Netscape etc


Stop a while and think with me. Do you guys agree with me that it is a common point that ASP.NET controls should render with no hassle in any browser?
Sure. but lately I haven't seen this happening in my Mozilla FireFox.
The page which is perfect in my IE60; it just looks *terrible* when navigating on Mozilla FireFox.

Doing some research in the net (of course) I found out that ASP.NET by default targets HTML 4.01 and CSS. For other browsers such as Netscape, the ASP.NET browser detection engine classifies them as down-level browsers, so do not be surprised if you see pages rendering in HTML 3.0 when your open-source browser can perfectly show HTML 4.0 content.
To avoid that, add these lines to your web.config:

#browserCaps#
#result type="System.Web.HttpBrowserCapabilities, System.Web, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /#
#use var="HTTP_USER_AGENT" /#
#TagWriter=System.Web.UI.HtmlTextWriter /#
#/browserCaps#

note: # means the opening and closing XML tags... blogger.com does not support XML comments.

That will push HTML 4.0 content, no matter the browser is. Of course, you do not want to force this always I guess, so just play around with browserCaps and you can even make your app be 100% fully compatible with Netscape 6.x or 7, Mozilla 1.0, Opera etc and tell it to always use HTML 4.0

By

No comments:

Post a Comment