GIS development essay (6) -- specify servername and servicename in Web. config in mapnet

Source: Internet
Author: User
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 !!

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.