<%
@ Page Language
=
"
C#
"
AutoEventWireup
=
"
true
"
CodeFile
=
"
Default.aspx.cs
"
Inherits
=
"
_Default
"
%>
2
3 <! DOCTYPE html PUBLIC " -//W3C//DTD XHTML 1.0 Transitional//EN " " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
4 < html xmlns = " http://www.w3.org/1999/xhtml " >
5 < head runat = " server " >
6 < title > Get weather </ title >
7 < script type = " text/javascript " language = " javascript " >
8 function RequestByGet(erea,province) ... {
9
10 var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
11 var URL;
12 if(erea==null)
13 URL="http://localhost/WeatherForecast/Service.asmx/GetEreas?";
14 else if(erea!=null && province==null)
15 URL="http://localhost/WeatherForecast/Service.asmx/GetProvinceFromErea?strErea="+escape(erea);
16 else if (erea!=null && province!=null)
17 URL="http://localhost/WeatherForecast/Service.asmx/GetCitiesFromProvince?strErea="+escape(erea)+"&strProvince="+escape(province);
18
19 xmlhttp.Open("GET",URL, false);
20 xmlhttp.SetRequestHeader ("Content-Type","text/xml; charset=utf-8");
21 xmlhttp.SetRequestHeader ("SOAPAction","http://www.itym.cn/img/6e44d6b2-2962-4109-be24-ad3e09eb3bf8.pngn style="COLOR: #000000">");
22 xmlhttp.Send(null);
23 var result = xmlhttp.status;
24
25 if(result==200) ...{
26 return xmlhttp.responseText;
27 }
28 xmlhttp = null;
29}
30
31 function BindObject(bindtype,erea,province)
32 ... {
33 var body=RequestByGet(erea,province);
34 var doc=new ActiveXObject("MSXML2.DOMDocument");
35 doc.loadXML(body);
36 var nodelist;
37 nodelist=doc.selectNodes("//string");
38 for(var i=0;i<nodelist.length;i++)
39 ...{
40 var op=new Option(nodelist.item(i).text);
41 if(bindtype=="erea")
42 form1.erea.options[i]=op;
43 else if(bindtype=="province")
44 form1.province.options[i]=op;
45 else
46 form1.city.options[i]=op;
47 }
48 }
49
50 function BindErea()
51 ... {
52 BindObject('erea',null,null);
53 var erea=form1.erea.options[form1.erea.selectedIndex].text;
54 BindObject('province',erea,null);
55 var province=form1.province.options[form1.province.selectedIndex].text;
56 BindObject('city',erea,province)
57
58 }
59
60 function BindProvince()
61 ... {
62 var erea=form1.erea.options[form1.erea.selectedIndex].text;
63 form1.province.options.length=0;
64 BindObject('province',erea,null);
65 var province=form1.province.options[form1.province.selectedIndex].text;
66 form1.city.options.length=0;
67 BindObject('city',erea,province)
68
69 }
70 function BindCity()
71 ... {
72
73 var erea=form1.erea.options[form1.erea.selectedIndex].text;
74 var province=form1.province.options[form1.province.selectedIndex].text;
75 form1.city.options.length=0;
76 BindObject('city',erea,province)
77 }
78
79 function GetWeather()
80 ... {
81 var erea=form1.erea.options[form1.erea.selectedIndex].text;
82 var province=form1.province.options[form1.province.selectedIndex].text;
83 var city=form1.city.options[form1.city.selectedIndex].text;
84 var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
85 var URL="http://localhost/WeatherForecast/Service.asmx/GetWeather?Erea="+escape(erea)+"&Province="+escape(province)+"&City="+escape(city);
86 xmlhttp.Open("GET",URL, false);
87 xmlhttp.SetRequestHeader ("Content-Type","text/xml; charset=utf-8");
88 xmlhttp.SetRequestHeader ("SOAPAction","http://www.itym.cn/img/6e44d6b2-2962-4109-be24-ad3e09eb3bf8.pngn style="COLOR: #000000">");
89 xmlhttp.Send(null);
90 var result = xmlhttp.status;
91 if(result==200)
92 ...{
93 var doc=new ActiveXObject("MSXML2.DOMDocument");
94 var response=xmlhttp.responseText;
95 doc.loadXML(response);
96 showWeather.innerText=response;
97 showCity.innerText=doc.selectSingleNode("//City").text;
98 showSunSet.innerText=doc.selectSingleNode("//SunRiseTime").text;
99 showSunRise.innerText=doc.selectSingleNode("//SunSetTime").text;
100 showWeather.innerText=doc.selectSingleNode("//Weather").text;
101 showWeather.innerText=doc.selectSingleNode("//Weather").text;
102 showDegree.innerText=doc.selectSingleNode("//Degree").text;
103 showDegree.innerText=doc.selectSingleNode("//Degree").text;
104 showDay.innerText=doc.selectSingleNode("//Day").text;
105 }
106
107 }
108
109 </ script >
110 </ head >
111 < body onload = " BindErea() " >
112 < form id = " form1 " runat = " server " >
113 < div >
114 地区: < select name = " erea " onchange = " BindProvince() " ></ select >
115 & nbsp; & nbsp;省份:
116 < select name = " province " onchange = " BindCity() " ></ select >& nbsp; & nbsp; < select name = " city " ></ select >
117
118 < input type = " button " value = " Click " onclick = " GetWeather() " />
119 < br />
120 < table border = " 1 " style = " background-color:Green " >
121 < tr >
122 < td > 城市: </ td >< td >< span id = " showCity " ></ span ></ td >
123 </ tr >
124 < tr >
125 < td > 日出: </ td >< td >< span id = " showSunRise " ></ span ></ td >
126 </ tr >
127 < tr >
128 < td > 日落: </ td >< td >< span id = " showSunSet " ></ span ></ td >
129 </ tr >
130
131 < tr >
132 < td > 天气: </ td >< td >< span id = " showWeather " ></ span ></ td >
133 </ tr >
134 < tr >
135 < td > 气温: </ td >< td >< span id = " showDegree " ></ span ></ td >
136 </ tr >
137 < tr >
138 < td > 星期: </ td >< td >< span id = " showDay " ></ span ></ td >
139 </ tr >
140 </ table >
141
142 </ div >
143 </ form >
144 </ body >
145 </ html >
146
2
3 <! DOCTYPE html PUBLIC " -//W3C//DTD XHTML 1.0 Transitional//EN " " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
4 < html xmlns = " http://www.w3.org/1999/xhtml " >
5 < head runat = " server " >
6 < title > Get weather </ title >
7 < script type = " text/javascript " language = " javascript " >
8 function RequestByGet(erea,province) ... {
9
10 var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
11 var URL;
12 if(erea==null)
13 URL="http://localhost/WeatherForecast/Service.asmx/GetEreas?";
14 else if(erea!=null && province==null)
15 URL="http://localhost/WeatherForecast/Service.asmx/GetProvinceFromErea?strErea="+escape(erea);
16 else if (erea!=null && province!=null)
17 URL="http://localhost/WeatherForecast/Service.asmx/GetCitiesFromProvince?strErea="+escape(erea)+"&strProvince="+escape(province);
18
19 xmlhttp.Open("GET",URL, false);
20 xmlhttp.SetRequestHeader ("Content-Type","text/xml; charset=utf-8");
21 xmlhttp.SetRequestHeader ("SOAPAction","http://www.itym.cn/img/6e44d6b2-2962-4109-be24-ad3e09eb3bf8.pngn style="COLOR: #000000">");
22 xmlhttp.Send(null);
23 var result = xmlhttp.status;
24
25 if(result==200) ...{
26 return xmlhttp.responseText;
27 }
28 xmlhttp = null;
29}
30
31 function BindObject(bindtype,erea,province)
32 ... {
33 var body=RequestByGet(erea,province);
34 var doc=new ActiveXObject("MSXML2.DOMDocument");
35 doc.loadXML(body);
36 var nodelist;
37 nodelist=doc.selectNodes("//string");
38 for(var i=0;i<nodelist.length;i++)
39 ...{
40 var op=new Option(nodelist.item(i).text);
41 if(bindtype=="erea")
42 form1.erea.options[i]=op;
43 else if(bindtype=="province")
44 form1.province.options[i]=op;
45 else
46 form1.city.options[i]=op;
47 }
48 }
49
50 function BindErea()
51 ... {
52 BindObject('erea',null,null);
53 var erea=form1.erea.options[form1.erea.selectedIndex].text;
54 BindObject('province',erea,null);
55 var province=form1.province.options[form1.province.selectedIndex].text;
56 BindObject('city',erea,province)
57
58 }
59
60 function BindProvince()
61 ... {
62 var erea=form1.erea.options[form1.erea.selectedIndex].text;
63 form1.province.options.length=0;
64 BindObject('province',erea,null);
65 var province=form1.province.options[form1.province.selectedIndex].text;
66 form1.city.options.length=0;
67 BindObject('city',erea,province)
68
69 }
70 function BindCity()
71 ... {
72
73 var erea=form1.erea.options[form1.erea.selectedIndex].text;
74 var province=form1.province.options[form1.province.selectedIndex].text;
75 form1.city.options.length=0;
76 BindObject('city',erea,province)
77 }
78
79 function GetWeather()
80 ... {
81 var erea=form1.erea.options[form1.erea.selectedIndex].text;
82 var province=form1.province.options[form1.province.selectedIndex].text;
83 var city=form1.city.options[form1.city.selectedIndex].text;
84 var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
85 var URL="http://localhost/WeatherForecast/Service.asmx/GetWeather?Erea="+escape(erea)+"&Province="+escape(province)+"&City="+escape(city);
86 xmlhttp.Open("GET",URL, false);
87 xmlhttp.SetRequestHeader ("Content-Type","text/xml; charset=utf-8");
88 xmlhttp.SetRequestHeader ("SOAPAction","http://www.itym.cn/img/6e44d6b2-2962-4109-be24-ad3e09eb3bf8.pngn style="COLOR: #000000">");
89 xmlhttp.Send(null);
90 var result = xmlhttp.status;
91 if(result==200)
92 ...{
93 var doc=new ActiveXObject("MSXML2.DOMDocument");
94 var response=xmlhttp.responseText;
95 doc.loadXML(response);
96 showWeather.innerText=response;
97 showCity.innerText=doc.selectSingleNode("//City").text;
98 showSunSet.innerText=doc.selectSingleNode("//SunRiseTime").text;
99 showSunRise.innerText=doc.selectSingleNode("//SunSetTime").text;
100 showWeather.innerText=doc.selectSingleNode("//Weather").text;
101 showWeather.innerText=doc.selectSingleNode("//Weather").text;
102 showDegree.innerText=doc.selectSingleNode("//Degree").text;
103 showDegree.innerText=doc.selectSingleNode("//Degree").text;
104 showDay.innerText=doc.selectSingleNode("//Day").text;
105 }
106
107 }
108
109 </ script >
110 </ head >
111 < body onload = " BindErea() " >
112 < form id = " form1 " runat = " server " >
113 < div >
114 地区: < select name = " erea " onchange = " BindProvince() " ></ select >
115 & nbsp; & nbsp;省份:
116 < select name = " province " onchange = " BindCity() " ></ select >& nbsp; & nbsp; < select name = " city " ></ select >
117
118 < input type = " button " value = " Click " onclick = " GetWeather() " />
119 < br />
120 < table border = " 1 " style = " background-color:Green " >
121 < tr >
122 < td > 城市: </ td >< td >< span id = " showCity " ></ span ></ td >
123 </ tr >
124 < tr >
125 < td > 日出: </ td >< td >< span id = " showSunRise " ></ span ></ td >
126 </ tr >
127 < tr >
128 < td > 日落: </ td >< td >< span id = " showSunSet " ></ span ></ td >
129 </ tr >
130
131 < tr >
132 < td > 天气: </ td >< td >< span id = " showWeather " ></ span ></ td >
133 </ tr >
134 < tr >
135 < td > 气温: </ td >< td >< span id = " showDegree " ></ span ></ td >
136 </ tr >
137 < tr >
138 < td > 星期: </ td >< td >< span id = " showDay " ></ span ></ td >
139 </ tr >
140 </ table >
141
142 </ div >
143 </ form >
144 </ body >
145 </ html >
146