Share via


ASP.NET Ajax : Javascript Problems with Migrated Legacy Projects - try the xhtmlConformance Spell!

If you have migrated an old project from ASP.NET 1.1 to 2.0 and subsequently changed the Web.config according to https://ajax.asp.net/docs/ConfiguringASPNETAJAX.aspx , but still not getting Ajax to work and JavaScript errors keep popping up, xhtmlConformance might just be the missing piece in the jigsaw!! Try looking for the following setting -

 <configuration>
.....
<system.web>
             .....

        < xhtmlConformance mode= "Legacy" />

            .....
    </system.web>
    .....
</configuration>

 
Either get rid of that at once, or set it to "Transitional" or "Strict"!! This is evil, and is always automatically appended to the Web.config after migration!!

 
Here are the steps we did, and even after that we kept getting the issue. Only after removing xhtmlConformance , we got it to work.

 

  •       
    Installed
    ASP.NET AJAX Extensions and ASP.NET AJAX Control Toolkit in the development
    server.

  •       
    Added
    a reference to System.Web.Extensions to the project

  •       
    Modified
    the Web.config as per all the steps mentioned at https://ajax.asp.net/docs/ConfiguringASPNETAJAX.aspx

  •        
    Added
    a ScriptManager control to the master page outside the ContentPlaceholder as

  •  <asp:ScriptManager
    ID="ScriptMgr1" runat="server"
    EnablePartialRendering="true"/>

  • <asp:ContentPlaceHolder
    ID="cntMain"
    runat="server"/>

  •      
    Added
    a UpdatePanel in a Content page surrounding a GridView and registered the
    button’s (which refreshes the GridView based on drop-down filters) Click event
    in the list of Triggers for the UpdatePanel as AsyncPostBackTrigger. The
    UpdateMode property of the UpdatePanel is set to Conditional.

  •   Even
    after this, when the Website is run and the button is clicked , it was
    refreshing the page with postback as before
    . We cannot figure out what is
    going on and why is Ajax not working on the site.

  •   We
    even tried having the button inside the UpdatePanel and set ChildrenAsTriggers
    to true with same results.

     

Thanks to the greatest Wizard, Scott, once again!! https://weblogs.asp.net/scottgu/archive/2006/12/10/gotcha-don-t-use-xhtmlconformance-mode-legacy-with-asp-net-ajax.aspx