An easy way to use Ajax in asp.net

Source: Internet
Author: User

Introduced

This article describes an easy way to write Web applications using AJAX and ASP.net. At the same time, the advantages and disadvantages of using Ajax are discussed. For illustrative purposes, this article gives the corresponding JavaScript code and uses C #. NET writes the ASP.net code.

Why use Ajax

Perhaps most people already know that Ajax means asynchronous JavaScript and XML (asynchronous JavaScript and XML). As far as I know, this technology was originally presented by Microsoft in 1999, which is known as the "Dhtml/javascript Web application using remote invocation (calls)." The core of this technology is to send an asynchronous HTTP request through the browser to invoke the server's Web page or service, and after the result is returned, the entire page can be updated without refreshing. This technology is constantly being perfected, and to this end, Web programs using Ajax are behaving much like Windows programs.

Because the implementation of this technology needs to rely on the front-end browser, it is limited in its use. But in recent years, thanks to the enhancement of browser capabilities and the performance of many AJAX-based applications such as Google and Amazon.com, the technology has finally made the Phoenix Nirvana and horny.

Ajax is now used very widely, and any dynamic Web page with a rich user experience will invariably use Ajax.

Solution

The method of using Ajax described in this article is very simple and efficient. This approach is also very easy to maintain, and developers can implement it without any special skills, and can also be used across browsers in this way.

A basic AJAX implementation requires two main parts: a client-side HTML page written in JavaScript code that sends requests and receives responses to the server, and a remote page that can receive requests and send response information to clients. The task of the client's JavaScript code is to create a XMLHTTP object, then send the request information to the server and finally handle the response information returned by the server by way of a callback. All of this is done by JavaScript code.

The example of this article uses ASP.net program implementation, in the implementation of the following points:

1. Ajax can send requests to different service-side pages on different asp.net pages.

2. The remote page URL can contain dynamically computable parameters, which makes it easier to create a URL string in the asp.net back-end code.

3. A remote page can respond with complex data before updating an HTML page, which can also be done by asp.net back-end code.

4. A server-side page can be an extended third party page, or it can be a Web page or service of its own.

The above points are shown in Figure 1

Figure 1

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.