Posts Tagged ‘AJAX’

ASP.NET AJAX & XHTML Conformance

Posted: July 25, 2008 in AJAX, ASP.NET
Tags: ,

For the past few days I faced strange problems while implementing ASP.NET AJAX UpdatePanel in an application running on framework 3.5.The same page was using ASP.NET AjAX ScriptService perfectly fine.On examining the HTML source of the page I found that the markup and <script> tags required for proper functioning of ASP.NET Ajax was not emitted at all.This application was actually migrated from 1.1 to 3.5 using the application migration wizard.While migrating the application the wizard adds the following lines of code web.config

<xhtmlConformance mode=”Legacy” />
This was the main culprit.The markup emitted by framework 1.1 is not XHTML compliant.So to maintain compatibility the xhtnmlConformance mode is set to Legacy.The other two values are “Strict” and “Transitional”.ASP.NET AJAX UpdatePanel does not work properly with XHTML Conformance mode legacy.Changing the mode to Strict or Transitional was causing distortion and javascript related issues.In legacy mode the id of the server controls is rendered as UserControlID:ControlID whereas in mode Strict or Transitional it is rendered as UserControlID$ControlID.

So we evaluated the option of setting XHTML conformance mode to Legacy for the existing folders and Transitional or Strict for the folder containing new web pages using the <location> tag in Web.config.This also did not workout as the application uses FrontController pattern for page to page and menu navigation.So all the requests are first send to the frontconroller and then to individual pages using Server.Transfer.As the requests are not directly routed to pages in the new folder XHTML conformance mode was not changed.

So we added another aspx pointing to the same httpHandler and manipulated the location tag as follows:

         <add verb="*"
         <add verb="*"
<location path=".">
	<xhtmlConformance mode="Legacy"/>

<location path="NewFrontController.aspx">
	<xhtmlConformance mode="Transitional"/>

This led to proper functioning of the UpdatePanel.