Brief Introduction to ASP. NET and Ajax implementation methods

Source: Internet
Author: User

AjaxIt should not be a technology, it is just an idea, with 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 I think it is a little lazy 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

The following is a reference clip:

 
 
  1. private void Page_Load(object sender, System.EventArgs e)  
  2. {  
  3. AjaxPro.Utility.RegisterTypeForAjax(typeof(DataAccess.MyAjax));  

In addition, the ASPX page must contain a Runat = Server tag. In this way, Ajax.net will load some common functions used and your custom functions. If not, you can load them, you can add them manually. 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, write less code, and do more.

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 concise javaScript library that allows you to easily process HTML documents, events, 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. Click the Button to trigger a JS function:

The following is a reference clip:

 
 
  1. function GetNews()  
  2. {  
  3. $("#News").html("Loading News......");  
  4. $.ajax({  
  5. type:"post",  
  6. url:"/ajax.aspx?act=getnews",  
  7. dataType:"html",  
  8. data:"",  
  9. success:function(result)  
  10. {  
  11. $("#News").html(result);  
  12. }  
  13. });  

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!

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.