Implementation of ASP. NET and Ajax

Source: Internet
Author: User
Ajax should not be a technology, but an idea, just like ASP. net and other Web development languages. Here we will talk about ASP. net and other excellent Ajax frameworks.

Ajax has been very popular for a while, and now it seems a little boring to talk about Ajax ,-_____-'''. Currently, the so-called Web 2.0 website basically does not use Ajax. Just like using RSS, it is like a tag, which is labeled. The purpose of AJAX is to allow users to not refresh all pages when triggering some operations. They only refresh some pages to be updated and load data, the loading image is used to indicate that the data is being loaded. It does not only look good, but also improves the user's access experience and has a cool feeling.

As for Ajax used in ASP. NET, I think most people use the Atlas framework included in ajax.net/ajaxprofessional or ASP. NET 2.0. I think these are not good Ajax solutions because they have been used.

Ajaxpro is not very convenient to use. The page needs to be registered in page_load, similar

Private   Void Page_load ( Object sender, system. eventargs E)
{
Ajaxpro. Utility. registertypeforajax ( Typeof (dataaccess. myajax ));
}

In addition, the ASPX page must contain a <asp: From> tag of runat = server. In this way, ajax.net will load some common functions and custom functions used. If no <asp: you can also manually add from>. However, some problems often occur in my previous applications. For example, I often find JS script errors in the browser Status Bar, and all the Ajax effects you have made will be invalid at this time, the solution is to put that Ajax. dll/ajaxpro. the dll can be overwritten again. The reason for the problem is unknown.

As for Atlas, I actually feel the same way as the DataGrid. Well, this kind of control is easy to use and convenient to use. However, when we really do some Web applications, you have to consider performance, layering, and other issues. I think, in a relatively formal web application, few people use the DataGrid to display some data. We recommend that you use these controls as few as possible. In addition, the execution efficiency of Atlas is indeed not ideal, and it has been loading there for a long time. After waiting for a long time, there was a script error and sweat.

Is there any other solution? You can write some JavaScript Functions for implementation. However, I recommend using the jquery JavaScript framework here. I will introduce it from Baidu Encyclopedia:

Jquery is another excellent javascr into pT framework after prototype. Its purpose is to write less, do more, and write lessCodeTo do more things.
It is a lightweight JS Library (only 21 K after compression), which is not suitable for other JS libraries. It is compatible with css3 and various browsers (IE 6.0 +, FF 1.5 +, safari 2.0 +, opera 9.0 + ).
Jquery is a fast and conciseJavascriptLibrary, allowing you to easily process HTML documents, events, and animation effects, and provide Ajax interaction for websites.
Another major advantage of jquery is its comprehensive documentation and detailed description of various applications. There are also many mature plug-ins to choose from.
Jquery can ensure that the user's HTML page is separated from the code and HTML content. That is to say, you don't need to insert a bunch of JavaScript code in the HTML to call the command. You just need to define the ID.

It seems that you will know that the Ajax effect is only one of the many functions of jquery. In general, the use of Ajax in Web applications is also inseparable from JavaScript, jquery encapsulates some JS functions for you, so that you are not worried about the complexity of JS. jquery will help you implement everything.

Looking at a small example, we can see that it is too convenient to use jquery for Ajax.

For example, An ASPX or HTML page contains a button. Click to trigger ajax to load data and display it in <span id = News>. Click the button to trigger a JS function:

Function Getnews ()
{
$ ( " # News " Pai.html ( "Loading news ...... " );
$. Ajax ({
Type: " Post " ,
URL: " /Ajax. aspx? Act = getnews " ,
Datatype: " Html " ,
Data: "" ,
Success: Function (Result)
{
$ ( " # News " Pai.html (result );
}
});
}

This function will first display "loading news .... ", access/ajax through asynchronous calls. on the ASPX page, the URL parameter act = News is passed to tell the page what type of data is required. You can use Ajax based on different parameters. aspx directly writes to the page, and then returns it to the above JS function and presents it to the page. That's easy!

Of course, jquery does not only have this Ajax effect implementation method. Here we provide some jquery resources. It takes a few hours to learn about them. It is worth the following:

Jquery Official Website: http://jquery.com/
Jquery API documentation: http://jquery.org.cn/visual/cn/index.xml
Jqeury Chinese Tutorial: http://www.k99k.com/jQuery_getting_started.html

There are many other excellent JavaScript frameworks, such as Yahoo! User Interface library, prototype, Rico, qooxdoo, and dojo. For more information about Ajax resources, see the resources collected here.

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.