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

<system.web>
        
<xhtmlConformance mode=”Legacy” />
</
system.web>
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:

<configuration>
   <system.web>
      <httpHandlers>
         <add verb="*"
              path="OldFrontController.aspx"
              type="MyHandler.New,MyHandler"/>
         <add verb="*"
              path="NewFrontController.aspx"
              type="MyHandler.New,MyHandler"/>
     </httpHandlers>
   <system.web>
<location path=".">
	<xhtmlConformance mode="Legacy"/>

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

This led to proper functioning of the UpdatePanel.

Advertisements
Comments
  1. Alexander S. says:

    Nice description. Thanx, it solved my problem!

  2. Selva Kumar J says:

    Hi

    I’m in need of some help from you. Have tried implementing the way you have shown in the article, but unable to get the desired result. Please help me in implementing the same.

    Please mail @ selvakumar.jospeh@softbrands.com, samples if possible else the detailed way of implementation.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s