<%@ Register TagPrefix=mobile
Namespace=SystemWebUIMobileControls
Assembly=SystemWebMobile %><%@ Page language=c#
Codebehind=weatheraspxcs Inherits=goodwaplifeweather
AutoEventWireup=false %><mobile:form id=Form runat=server>
<FONT face=宋体>
<mobile:Label id=Label runat=server
FontBold=True>【生活资讯】</mobile:Label>
<mobile:Label id=Label runat=server
FontItalic=True>==天气预报==</mobile:Label>
<mobile:Label id=l_date runat=server></mobile:Label>
<mobile:Label id=l_city runat=server></mobile:Label>
<mobile:Label id=l_wea runat=server></mobile:Label>
<mobile:Label id=l_sky runat=server></mobile:Label>
<mobile:Label id=l_w runat=server></mobile:Label>
<mobile:Label id=l_w runat=server></mobile:Label>
<mobile:Label id=l_w runat=server></mobile:Label>
<mobile:Label id=Label runat=server>【请选择城市名】</mobile:Label>
<mobile:SelectionList id=s_weather runat=server>
<Item Value=深圳 Text=深圳 Selected=True></Item>
<Item Value=广州 Text=广州></Item>
<Item Value=上海 Text=上海></Item>
<Item Value=北京 Text=北京></Item>
<Item Value=天津 Text=天津></Item>
<Item Value=武汉 Text=武汉></Item>
<Item Value=重庆 Text=重庆></Item>
<Item Value=成都 Text=成都></Item>
<Item Value=南京 Text=南京></Item>
<Item Value=香港 Text=香港></Item>
<Item Value=澳门 Text=澳门></Item>
</mobile:SelectionList>
<mobile:Command id=Command runat=server>查 询</mobile:Command>
<mobile:Link id=Link runat=server
NavigateUrl=/defaultaspx#Goodview>首
页</mobile:Link></FONT></mobile:form>
public class weather : SystemWebUIMobileControlsMobilePage
{
protected SystemWebUIMobileControlsLabel Label;
protected SystemWebUIMobileControlsLabel Label;
protected SystemWebUIMobileControlsSelectionList s_weather;
protected SystemWebUIMobileControlsLabel l_date;
protected SystemWebUIMobileControlsLabel l_city;
protected SystemWebUIMobileControlsLabel l_wea;
protected SystemWebUIMobileControlsLabel l_sky;
protected SystemWebUIMobileControlsLabel l_w;
protected SystemWebUIMobileControlsLabel l_w;
protected SystemWebUIMobileControlsLabel l_w;
protected SystemWebUIMobileControlsLink Link;
protected SystemWebUIMobileControlsCommand Command;
protected SystemWebUIMobileControlsLabel Label;
protected SystemWebUIMobileControlsForm Form;
private void Page_Load(object sender SystemEventArgs e)
{
// 在此处放置用户代码以初始化页面
if (!PageIsPostBack)
{
string city = 深圳;
int startstop;
string weatherweatherwea;
string wea_city = weather_city(city);
wea_city = wea_cityReplace( );
start = wea_cityIndexOf(<b>wea_cityLength);
stop = wea_cityIndexOf(</b> start);
weather = wea_citySubstring(start stopstart)Trim() + ;
weather = weatherSubstring()Trim();
start =
wea_cityIndexOf(<td>wea_cityLength);
stop = wea_cityIndexOf(℃start) + ;
weather = wea_citySubstring(start stopstart);
weather = weatherSubstring(stopstart)Trim();
weather = weatherReplace( );
start = wea_cityIndexOf(<fontcolor=#><b>
wea_cityLength);
stop = wea_cityIndexOf(</b></font>start);
wea = wea_citySubstring(startstopstart);
wea = weaSubstring(weaLength) + kbrk;
wea = weaReplace( );
wea = weaReplace(> k);
wea = weaReplace(< k);
wea = weaReplace(kbrk k);
string [] wall = null;
char[] seperator = {k};
wall = weaSplit(seperator);
/**///////////////////////////////////////
l_cityText = [城市] + city;
l_weaText = [天气] + weather;
l_skyText = [温度] + weather;
/**////////
l_dateText = wall[];
l_wText = wall[];
l_wText = wall[];
l_wText = wall[];
}
}
Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASPNET Web 窗体设计器所必需的
//
InitializeComponent();
baseOnInit(e);
}
/**//// <summary>
/// 设计器支持所需的方法 不要使用代码编辑器修改
/// 此方法的内容
/// </summary>
private void InitializeComponent()
{
thisCommandClick += new SystemEventHandler(thisCommand_Click);
thisLoad += new SystemEventHandler(thisPage_Load);
}
#endregion
private void Command_Click(object sender SystemEventArgs e)
{
string city = s_weatherSelectionValueTrim();
int startstop;
string weatherweatherwea;
string wea_city = weather_city(city);
wea_city = wea_cityReplace( );
start = wea_cityIndexOf(<b>wea_cityLength);
stop = wea_cityIndexOf(</b> start);
weather = wea_citySubstring(start stopstart)Trim() + ;
weather = weatherSubstring()Trim();
start =
wea_cityIndexOf(<td>wea_cityLength);
stop = wea_cityIndexOf(℃start) + ;
weather = wea_citySubstring(start stopstart);
weather = weatherSubstring(stopstart)Trim();
weather = weatherReplace( );
start = wea_cityIndexOf(<fontcolor=#><b>
wea_cityLength);
stop = wea_cityIndexOf(</b></font>start);
wea = wea_citySubstring(startstopstart);
wea = weaSubstring(weaLength) + kbrk;
wea = weaReplace( );
wea = weaReplace(> k);
wea = weaReplace(< k);
wea = weaReplace(kbrk k);
string [] wall = null;
char[] seperator = {k};
wall = weaSplit(seperator);
/**///////////////////////////////////////
l_cityText = [城市] + city;
l_weaText = [天气] + weather;
l_skyText = [温度] + weather;
/**////////
l_dateText = wall[];
l_wText = wall[];
l_wText = wall[];
l_wText = wall[];
}
public string weather_city(string city)
{
string temp = null;
try
{
string strURL =
bin/figureWeather/searchcgi;
HttpWebRequest request;
request = (HttpWebRequest)WebRequestCreate(strURL);
requestMethod=POST; //Post请求方式
requestContentType=application/xwwwformurlencoded; //内容类型
string paraUrlCoded = SystemWebHttpUtilityUrlEncode(city);
//参数经过URL编码
paraUrlCoded = paraUrlCoded + = +
SystemWebHttpUtilityUrlEncode(city
SystemTextEncodingGetEncoding(GB));
byte[] payload;
payload =
SystemTextEncodingGetEncoding(GB)GetBytes(paraUrlCoded);
//将URL编码后的字符串转化为字节
requestContentLength = payloadLength; //设置请求的ContentLength
Stream writer = requestGetRequestStream(); //获得请求流
writerWrite(payloadpayloadLength); //将请求参数写入流
writerClose(); //关闭请求流
HttpWebResponse response;
response = (HttpWebResponse)requestGetResponse(); //获得响应流
Stream s;
s = responseGetResponseStream();
StreamReader objReader = new
StreamReader(sSystemTextEncodingGetEncoding(GB));
string HTML = ;
string sLine = ;
int i = ;
while (sLine!=null)
{
i++;
sLine = objReaderReadLine();
if (sLine!=null)
HTML += sLine;
}
HTML = HTMLReplace(<<);
HTML = HTMLReplace(>>);
int startstop;
start = HTMLIndexOf(<img
src=HTMLLength);
stop = HTMLIndexOf(<td
background=start);
temp = HTMLSubstring(start stop start);
}
catch (Exception x)
{
}
return temp;
}
}