High-speed database access using ASP. NET callback and JavaScript

Source: Internet
Author: User
Tags website performance

The client callback technology of ASP. NET enables direct communication between JavaScript and. net, and implements web applications at a high speed far faster than the updatepanel control.Program. This post provides an example of ASP. NET callback download.CodeTo achieve real-time keyword queries similar to Google, and the performance is superb, the response speed of the program is as fast as JavaScript.

When you see the summary of this post, you may think that the callback technology is amazing. Indeed, the data transmission volume and execution speed are far better than the updatepanel control of ASP. NET Ajax. If you use some network monitoring tools, you can see that in many cases, the data volume transmitted by callback over the network is even dozens or even hundreds of times less than the updatepanel control.

However, callback is an old technology that ASP. NET 2.0 has introduced. It can even be said that it is only a set of transitional technologies before the emergence of the Microsoft Ajax framework. Its functions and functions are extremely limited, so they are not suitable for developing complex applications. Therefore, it is far less convenient to develop than ASP. NET Ajax controls and updatepanel controls. But it is undeniable that callback is still a pretty good choice for some pages that require high performance and fast response.

This post provides two simple examples for downloading. The first example can be used to query SQL Server when the onblur, onkeyup, and other JavaScript events of textbox are triggered, in addition, onkeyup can achieve the Google-like real-time key-in query results. In the second example, the database will be queried through button click.

-------------------------------------------------
Sample Code download point of this post:
Http://files.cnblogs.com/WizardWu/090208.zip

(In this example, the SQL server's northwind database and IIS or vs 2008 are required)
-------------------------------------------------

 


Figure 1 when the textbox is left (onblur), the database is queried at an extremely fast speed.

 

Just like the previous "What should I do if my website performance is getting worse? And the followingArticleMentioned:

Updatepanel tips and tips (msdn magazine, 2007/6 ):
Http://msdn.microsoft.com/zh-cn/magazine/cc163413.aspx

Microsoft sacrificed a lot of performance to achieve ease of use of Ajax, making the updatepanel control inefficient, because it saves a lot of page states with viewstate. On the other hand, although the callback technology is fast, the network transmission volume is far less than the updatepanel control, but its disadvantage is that the function is too busy and the development is inconvenient. I also found a disadvantage for the support team, it is in its raisecallbackevent method that will make response. the alert of write and JavaScript fails, causing the captured error information, which cannot be displayed on the page for programmers and users to know.

I also heard that when ASP. NET 4.0 is used, the updatepanel control's render method will be improved. You can only render the specific page field value, which will focus on smaller blocks than partial rendering. Before that, if your page needs to implement simple functions with excellent performance, such as the example of this post, callback is still a good choice.

 

 

--------------------------------------------------

Reference file:

[1] icallbackeventhandler Interface
Http://msdn.microsoft.com/zh-cn/library/system.web.ui.icallbackeventhandler (vs.80). aspx
Http://msdn.microsoft.com/zh-cn/library/system.web.ui.icallbackeventhandler_members (vs.80). aspx

[2] ASP. NET 2.0 books written by Dong Dawei, Yan jianghua, and others

[3] Performance Comparison Between callback and updatepanel
Http://www.cnblogs.com/jeff377/archive/2007/12/09/988347.html

[4] network files

 

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.