Do not use mode = "Legacy" in ASP. net ajax"

Source: Internet
Author: User

Developers have encountered some weird JavaScript problems that may occur when using ASP. net ajax and some of their custom JavaScript scripts.

The main cause of the problem is that they automatically transplanted the VS 2003 Web project to VS 2005 and configured the following in their web. config file: .

If you have compiled a custom client JavaScript script in your web application and will use AJAX, read it and learn how to avoid this common problem.

Symptom:

When you successfully Add a new client JavaScript script to a previously upgraded project from VS 2003 to VS 2005, you will see strange behavior. When using the ASP. net ajax UpdatePanel control, this strange behavior sometimes involves page-wide postback, not just incremental local updates.

When you open your web. config file, you will see Element, like this:



Background:

Many server-side controls in ASP. NET 1.0 and 1.1 do not output XHTML-compatible identifiers. ASP. NET 2.0 has changed this. By default, all server-side controls will output XHTML-compatible identifiers.

However, one thing we noticed in the early ASP. NET 2.0 beta was that when we upgraded the customer application, many applications would assume that the page output is not compatible with XHTML. If we change the default output of the control on our server to be compatible with XHTML, it sometimes modifies the visual display of the page. For backward compatibility purpose, we added the above Settings, allowing developers to set controls in Legacy mode (that is, with ASP. NET 1.1, it outputs non-XHTML identifiers), Transitional mode (XHTML Transitional), or Strict mode (XHTML Strict.

By default, when you use VS 2003 to upgrade to VS 2005 Web project porting wizard (whether it is a website or web application project), your web. this legacy configuration is added to the config file.

Solution:

Unless you know there is a problem when your website runs in XHTML mode (but you don't have time to correct it), I always recommend removing it from your web. config file. This part, or you can explicitly set it to Transitional or Strict.

This will make your HTML output conform to the standard. In addition, this will also cause the HTML output of your server control to be well formed, that is, the start tag always matches the end tag. This is especially important when you use AJAX technology to dynamically Replace the content of some HTML elements on your page. Otherwise, the client JavaScript script sometimes cannot clearly understand the container elements, leading to errors. It will also ensure that ASP. net ajax will work properly on your website.

(

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: info-contact@alibabacloud.com 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.