code-u-like

C#, .Net, Sql Server, Salesforce, Dynamics CRM etc,
Charity and Not-for-Profit sector

Tuesday, June 12, 2007

ASP.NET 1.1 Panels render as tables in Firefox?

ASP.NET Panels are expected to render as <DIV> elements, but poking around with Firefox and FireBug the other day I was surprised to see them rendered as single-cell tables. It turns out that, by default, ASP.NET 1.x treats Firefox as a completely incompetent browser that can't even handle <DIV>s properly.

Though this sounds like another strike in the browser wars between IE and Firefox, apparently it is an accident of the development schedule of ASP.NET 1.1. Firefox's usage expanded so quickly after its initial release, that ASP.NET's handling of it was quickly out of date.

So, ASP.NET 1.1 treats Firefox as a 'downlevel' browser, and assumes it has only basic support for CSS, DOM and Javascript. Fortunately, this can be changed by adding a carefully-tuned <browserCaps> section inside the <system.web> section of web.config or machine.config. Get the <browserCaps> right, and ASP.NET will then treat Firefox as 'uplevel'. Note that ASP.NET 2.0 treats Firefox as uplevel by default, so doesn't need this fix.

The <browserCaps> syntax is pretty wierd, but an example (along with a much more detailed discussion of the problem) can be found in Bart Gerardi's article here:
Rendering to Firefox from ASP.NET
The article also discusses other differences and things to look out for when using ASP.NET with Firefox.

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home