asp.net ajax client Programming trip (i)--hello! asp.net AJAX

Source: Internet
Author: User

Objective

I think it's amazing what web developers today say they haven't heard of Ajax technology. Indeed, in recent years, the word Ajax in a more than imagined speed of the web development field, large to Google, NetEase, small to some local companies home, are generally beginning to add AJAX elements. This technology brings revolutionary meaning to web development, and makes the user experience of Web products and b/s system greatly improved.

However, Ajax is gorgeous, refreshing, and difficult to develop. JavaScript language weird syntax, no IDE support, and difficult to debug, have become the mishap of Ajax development. In addition to B/s system and C/s, the diversity of browsers also brings many difficulties to the development of Ajax, making us do AJAX applications, we have to take into account the differences in various browsers, the development process is extremely painful.

In response to this situation, various AJAX frameworks emerged. One of the best of these is the ASP.net AJAX framework introduced by Microsoft. Not only does it make it much easier to develop AJAX applications, but it can also seamlessly integrate with Microsoft's development tools, making it much easier for developers of the. NET Platform.

This series of articles is about client programming for this framework.

What can asp.net ajax do?

The benefits and features of the ASP.net Ajax framework are too much, and here are a few brief columns:

1. The JavaScript language has been expanded to add object-oriented features. Simplifies the syntax of some DOM operations.

2. A series of server-side controls can allow programmers to not write JS, but only through the drag control to complete the development of AJAX applications.

3. Innovative concepts such as client-side components, behavioral components, and a tabbed language similar to XML are provided, bringing revolutionary innovations to AJAX client authoring.

4. Perfect agent model mechanism, make the developer can call the background program directly in JS, just like in the background call.

5. Automatic conversion of various data types, especially for complex types, built-in automatic serialization and deserialization mechanisms, yes, before and after the table can directly share complex types, without the need for manual conversion.

6. Provides a large number of client components to facilitate program development.

7. Masks the differences between browsers, allowing developers to stop dealing with the headaches of browser differences.

Server-side programming VS client Programming

The ASP.NET AJAX framework provides two development models: server-side programming and client programming. The former is easy to use, developers can not understand JS and Ajax, but through the traditional ASP.net development methods to complete the development of AJAX applications, but its control granularity is thicker. The latter is relatively difficult to develop, need developers familiar with JavaScript, and familiar with the ASP.net Ajax provides a variety of syntax support and client programming model, but its granular control granularity, is conducive to improving the performance and quality of applications.

This series of articles will focus on client programming.

Start asp.net ajax tour: Let's talk about asp.net ajax hello!

Below, I will implement one of the simplest AJAX applications in two ways: Click the button, call a method in the background class asynchronously, and return a string that appears at the specified location of the page, and the entire process does not refresh the page. The effect of the chart is as follows:

The picture on the left is clicked, and the right picture is clicked. The entire Process page is not refreshed and the displayed string is obtained from the background program. Here, you will implement this small application in two different ways.

No asp.net ajax days: To say hello is not easy! It's hard to be laborious!

First, we do not use any framework to create this AJAX application manually.

1. Create the project

Open vs (I'm using 2005) to create a new website named Ajaxtest. When you are finished, add the System folder App_Code.

2. Create a background program

Here we'll write a daemon for the foreground call, which is simple enough to return a string. We add a new file Hello.cs under the App_Code folder, which is a C # class file with detailed code as follows:

Hello.cs:

1using System;
2
3public class Hello
4{
5  public Hello() { }
6
7  public string SayHello()
8  {
9    return "Hello!Ajax";
10  }
11}

The code has nothing to explain, only one way is to return to "hello! Ajax "This string.

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.