First look at the web. config segment, as shown below: 1 <? XML version = "1.0" encoding = "UTF-8"?>
2 <configuration>
3 ......
4 <deleetask>
5 <add key = "servername" value = "lijigang"/>
6 <add key = "servicename" value = "map_jwd"/>
7 </appsettings>
8 ......
9 </configuration>
The following describes how to use the mapnet control to obtain the servername and servicename from the Web. config file:
1. Clear the servername and servicename attributes of the mapnet control on the page;
2. Write the following code in the pageload event on the page: 1 private void page_load (Object sender, system. eventargs E)
2 {
3 // place user code here to initialize the page
4 imapnet myimapnet = This. mapnet1;
5 controldatabind mycdb = new controldatabind ();
6 mycdb. mapnetservicebind ("servername", "servicename ");
7 myimapnet. servername = mycdb. mapnetserver;
8 If (! This. Page. ispostback)
9 {
10myimapnet. servicename = mycdb. mapnetservice;
11 //...... Other code
12}
13}
3. The mapnetservicebind method of the controldatabind class is used here: 1 using system;
2 ...... // Other references
3 namespace gongansys. Class
4 {
5/** // <summary>
6 // Control Data Binding operation class.
7 /// </Summary>
8 public class controldatabind
9 {
10 public controldatabind ()
11 {
12 //
13 // todo: add the constructor logic here
14 //
15}
16 Public String mapnetserver;
17 Public String mapnetservice;
18 "retrieve mapnet control service method" # region "retrieve mapnet control service method"
19/** // <summary>
20 // read the servername and servicename services of the mapnet control from the Web. config file.
21 /// </Summary>
22 // <Param name = "mymapserver"> the value of the attribute key of a node in appsettings in Web. config. (Servername) </param>
23 // <Param name = "mymapservice"> the value of the attribute key of a node in appsettings in Web. config. (Servicename) </param>
24 public void mapnetservicebind (string mymapserver, string mymapservice)
25 {
26 try
27 {
28 mapnetserver = system. configuration. configurationsettings. etettings [mymapserver];
29 mapnetservice = system. configuration. configurationsettings. deleetask[ mymapservice];
30}
31 catch
32 {
33 mapnetserver = "localhost ";
34 mapnetservice = "map_jwd ";
35}
36}
37 # endregion
38}
We believe that this will bind the mapnet control service.
Note: In line 2nd of code at, the servicename attribute must be placed in if (! This. Page. ispostback ){......} Block. Otherwise, operations such as enlarging or downgrading the map will be affected. Remember !!