In many applications, we will encounter the use of linkage drop-down boxes, such as industry linkages and geographic and regional linkages. Most linkages on the Internet are written in pure JavaScript, and the maximum level is only three-level linkage, in terms of updating data sources, adselect can solve this problem well and is easy to deploy. It supports unrestricted drop-down box interaction! Currently, only XML data sources are supported. database is supported in the next version! You can look at the simple effect :( http://sj.d0086.com/testadselect/default.aspx), the following simple instructions on how to deploy:
Deploy the ASPX page
1. Reference adselect. DLL to the project (add reference --- Select DLL file ).
2. Reference namespace:
Using advancedselect;
3. Switch to the ASPX page and register the user control <% @ register Assembly = "advancedselect" namespace = "advancedselect" tagprefix = "adselectuc" %>
4. Introduce the user control in the page body area <adselectuc: adselecthtml runat = "server"/>
The page deployment is complete. Next we will configure
Note: All configurations are completed on the client, and no configuration is required on the server!
Add the configuration code in the VaR C;
Function vvv (){
C = new adselect ();
C. defaultname = "Please select ";
C. loadtext = "loading data ";
C. isdisplayloadtext = true;
C. Build ("id1 ");
C. Load ();
}
</SCRIPT>
Note:
1. Declare a global variable (used to create an object) C.
2. Create an adselect object with the following methods and attributes:
(1) defaultname is the default character. Default Value: "Please select ";
(2) defaultvalue: default value for defaname name.
(3), loadtext: The content displayed during loading.
(4) isdisplayloadtext: whether to display loadtext during loading. The default value is true.
(5), build (): bind to the drop-down box. The parameter is the ID of the drop-down box. Multiple IDs can be input, for example, C. build ("id1", "ID2", "ID3 ").
(6), gettext (ID): Get the selected text in the drop-down box of the specified ID
(7), getvalue (ID): Get the selected value in the drop-down list of the specified ID
Now you have deployed the service!
Deploy data sources
For the XML data source, the default data source file name is adselectdatasource. xml. The data source structure is as follows. The Tag Name, name attribute, value attribute, and Id attribute cannot be changed.
<? XML version = "1.0" encoding = "UTF-8"?>
<Adselect>
<T name = "Guangdong" value = "GD" id = "1">
<T name = "Shenzhen" value = "SZ" id = "2">
<T name = "Luohu" value = "LH" id = "3">
<T name = "Huang beiling" value = "" id = "4">
<T name = "shangcun" value = "" id = "5"/>
</T>
<T name = "Changling" value = "" id = "7"/>
</T>
</T>
<T name = "Guangzhou" value = "GZ" id = "9"/>
</T>
<T name = "Hubei" value = "HB" id = "19">
<T name = "Jingzhou" value = "JZ" id = "10"/>
</T>
<T name = "Jiangxi" value = "JX" id = "12"> </T>
</Adselect>
Your data source must be configured according to the above architecture!
Adselect provides a built-in method to check the validity of the data source. The method is as follows:
Adselect ad = new adselect ();
Ad. checkxml ();
The running result is as follows:
Pay attention to the following points about the data source:
1. Currently, the data source only supports XML, and the XML architecture must be consistent with the above!
2. The data source file and path can be configured in Web. config, but the default is the adselectdatasource. xml file in the same directory as the file.
Configure the Web. config file
Configure the Web. config file
You can configure the file name and path of the data source under deleettings.
Note that "~ /"
<Deleetask>
<Add key = "adselect" value = "~ \ XML \ adselectdatasource. xml "/>
</Appsettings>
Add the following sub-nodes (required) to the <system. Web> node in the web. config file)
<System. Web>
//
<Httphandlers>
<Add Path = "adselect. axd" verb = "get" type = "advancedselect. adselectload, advancedselect"/>
</Httphandlers>
</System. Web>
So the configuration is complete. Now you can use adselect normally. The application is simple and convenient ....
Click to download this file