Ajaxpro. NET Framework generates efficient tree (Asp.net 2.0) (sample code download)

Source: Internet
Author: User

(1). Description

It is easier to use a tree to display menus and item lists (retrieve data from the server). Currently, a tree can be displayed in either of the following ways:

1. During tree initialization, all data is obtained from the server at a time. After the data is obtained, data is no longer required when the page is expanded or shrunk,

In this way, the validity rate of retrieved data is relatively high, but when there are many Tree nodes, there will be a great delay in each initialization.

2. Only the expanded nodes are loaded during initialization. When you need to view the data under a node, the data is retrieved again. In this way, the initialization delay will be

Reduce, but each time you click a node, You need to obtain the data, and the page needs to be refreshed every time, so there will be a delay.

This example uses ajax to implement the second method. Each time only the node data to be expanded is dynamically loaded (when the closed node is not expanded

In addition, the page is not refreshed when the node is loaded.

(2) running example Diagram

(3) Introduction to. ajaxpro. net

First, we will introduce ajaxpro. net. ajaxpro. NET is an excellent Ajax framework. In actual applications, you only need to add its DLL

Reference and perform simple configuration, that is, you can easily directly call the server method on the client to obtain the tree node.

(4) use ajaxpro. Net pre-Configuration

1. Add a reference to the ajaxpro. dll file (exampleCode).

2. Add the following configuration in the web. config file,

1 < Httphandlers >
2 < Add verb = " Post, get " Path = " Ajaxpro/*. ashx " Type = " Ajaxpro. ajaxhandlerfactory, ajaxpro "   />
3 </ Httphandlers > 3. Add the following code to the page_load event of *. aspx. CS on the page to use the ajaxpro. NET Framework: Ajaxpro. Utility. registertypeforajax ( Typeof (_ Default )); 4. After the preceding three steps, you only need to add the attribute [ajaxmethod] before the method on the backend server: 1 [Ajaxmethod ()] // Or [ajaxpro. ajaxmethod]
2 Public Arraylist getsearchitems ( String Strquery)
3 {
4 // Generate data sources
5 Arraylist items =   New Arraylist ();
6 Items. Add ( " King " );
7 Items. Add ( " Rose " );
8 Return Items;
9 }
10 You can directly use the server method on the client, which is very convenient. The client calls the background Code as follows: VaR returnvalue = Background code class name. getsearchitems (parameter ); Code: www.cnitblog.com/files/chengking/ajaxpro.net_efficienttree.rar Article Referenced from:
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.