Do not use mode= "Legacy" in ajax

Source: Internet
Author: User
Tags config net client

"Guide" If you write custom client JavaScript scripts in your Web application and you will use AJAX, you need to know how to avoid this common problem that is mentioned in this article.

Developers have encountered some strange javascript problems that arise when using AJAX and some of their custom JavaScript scripts.

The main reason for the problem is that they are automatically porting vs 2003 Web projects to VS 2005, and are also configured in their Web.config files.

If you've written custom client JavaScript scripts in your Web application and will use Ajax, read on to see how to avoid this common problem.


When you add a new client JavaScript script to a project that was previously successfully upgraded from VS 2003 to VS 2005, you see Strange behavior. When using the AJAX UpdatePanel control, this strange behavior sometimes includes pages that do whole pages postback, not just incremental local updates.

When you open your Web.config file, you will see the elements in it, like this:


Many server-side controls in 1.0 and 1.1 do not export XHTML-compliant identities. 2.0 has changed this, and by default, all server-side controls will output XHTML-compatible identities.

But one of the things we noticed in the early 2.0 beta is that when you upgrade your customer application, many applications assume that the page output is not XHTML compliant. By changing the default output of our server control to XHTML-compatible, it sometimes modifies the visual display of the page. For backwards compatibility purposes, we added the above setting to allow developers to set up controls in legacy mode (i.e., as with 1.1, output non-XHTML identities), or transitional mode (XHTML transitional), or Strict mode (XHTML Strict) display.

By default, this legacy configuration is added to your Web.config file when you use the VS 2003 upgrade to the Web Project Migration Wizard for VS 2005 (whether it is a Web site or Web application project).


Unless you know there is a problem with your site in XHTML mode (but you haven't had time to correct it), I always recommend that you remove this part from your Web.config file, or you can explicitly set it to transitional or Strict.

This will make your HTML output conform to the standard, and this will also cause your server control's HTML output to be well formed, that is, the start tag and end tag always match. This is especially important when you use AJAX technology to dynamically replace the content of certain HTML elements on your page, otherwise, client JavaScript scripts sometimes confuse container elements and cause errors. It will also ensure that Ajax will work properly on your site.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.