国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開(kāi)通VIP
天氣web service網(wǎng)站實(shí)例講解

http://www.webxml.com.cn/WebServices/WeatherWebservice.asmx天氣web service網(wǎng)站實(shí)例講解

步驟:

1.創(chuàng)建web引用。

首先建立個(gè)網(wǎng)站解決方案“website1",右擊 website1"網(wǎng)站解決方案,選擇“添加web引用”,出現(xiàn)對(duì)話框

在URL一欄里面加入web service網(wǎng)站網(wǎng)址,例如“http://www.webxml.com.cn/WebServices/WeatherWebservice.asmx

之后單擊“前往”按鈕,得到如下截圖效果


之后單擊“添加引用”按鈕,對(duì)話框關(guān)閉,你的解決方案里面就多了一個(gè)包含多層文件夾的東西,截圖如下

這樣,你的添加引用就成功了。但是要在C#后臺(tái)調(diào)用他,你還要繼續(xù)步驟二。

步驟二:創(chuàng)建個(gè)默認(rèn)文件weathers.aspx文件(自動(dòng)生成后臺(tái)weathers.aspx.cs文件)。

1.在weathers.aspx文件里面輸入以下代碼:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="weathers.aspx.cs" Inherits="weathers" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "

<html xmlns="<head runat="server">
<title>天氣情況</title>
</head>
<body>
<form id="form1" runat="server">
<table style="width:100%; background-color: #CCFFFF;" cellpadding="0"
cellspacing="0">
<tr>
<td style="line-height: 80px; font-size: large; color: #FF0000; height: 80px;"
colspan="2" align="center">

國(guó)內(nèi)外主要城市3天氣天氣預(yù)報(bào)實(shí)例
</td>
</tr>

<tr>
<td style=" font-size: medium; font-weight: bolder; width: 189px;">
選擇省/洲:<asp:DropDownList ID="DropDownList1" runat="server"
onselectedindexchanged="DropDownList1_SelectedIndexChanged"
AutoPostBack="True">
</asp:DropDownList>
</td>
<td style=" font-size: medium; font-weight: bolder;">
選擇城市:<asp:DropDownList ID="DropDownList2" runat="server"
onselectedindexchanged="DropDownList2_SelectedIndexChanged"
AutoPostBack="True">
</asp:DropDownList>
</td>
</tr>
<tr>
<td style="width: 189px">
 </td>
<td align="right">
<asp:Label ID="Label7" runat="server" Text="Label" ForeColor="Red" ></asp:Label>
</td>
</tr>
<tr>
<td colspan="2">
 </td>
</tr>
<tr>
<td style=" font-size: medium; font-weight: bolder;">
今日實(shí)況</td>
<td style="height: 22px">
<asp:Label ID="Label9" runat="server" Text="Label"></asp:Label>
</td>
</tr>

<tr>
<td colspan="2"></td>
</tr>
<tr>
<td style=" font-size: medium; font-weight: bolder;">
天氣預(yù)報(bào)(今天)</td>
<td>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Image ID="Image2" runat="server" />
<asp:Image ID="Image3" runat="server" />
</td>
</tr>
<tr>
<td colspan="2">
 </td>
</tr>
<tr>
<td style=" font-size: medium; font-weight: bolder;">
今天指數(shù)</td>
<td>
 </td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2">
 </td>
</tr>
<tr>
<td style=" font-size: medium; font-weight: bolder;">
天氣預(yù)報(bào)(明天)</td>
<td>
<asp:Label ID="Label4" runat="server" Text="Label"></asp:Label>
<asp:Image ID="Image4" runat="server" />
<asp:Image ID="Image5" runat="server" />
</td>
</tr>
<tr>
<td colspan="2">
 </td>
</tr>
<tr>
<td style=" font-size: medium; font-weight: bolder;">
天氣預(yù)報(bào)(后天)</td>
<td>
<asp:Label ID="Label5" runat="server" Text="Label"></asp:Label>
<asp:Image ID="Image6" runat="server" />
<asp:Image ID="Image7" runat="server" />
</td>
</tr>
<tr>
<td colspan="2">
 </td>
</tr>
<tr>
<td style=" font-size: medium; font-weight: bolder;">
城市介紹</td>
<td>
 </td>
</tr>
<tr>
<td style="width: 189px">
<asp:Image ID="Image1" runat="server" Height="130px" Width="210px" />
</td>
<td>
<asp:Label ID="Label6" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td style="width: 189px">
 </td>
<td>
 </td>
</tr>

<tr>
<td style="width: 189px">
 </td>
<td align="right">
預(yù)報(bào)時(shí)間:<asp:Label ID="Label8" runat="server" Text="Label"></asp:Label>
</td>
</tr>
</table>
</form>
</body>
</html>

2.在default1.aspx.cs文件里面輸入以下代碼:

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using cn.com.webxml.www; //注意此處就是引用web 服務(wù)的引用申明,注意不要把App_WebReferences加入進(jìn)去

//并且注意cn.com.webxml.www是倒過(guò)來(lái)寫的,相對(duì)于網(wǎng)址而言,但是是符合文件夾的層次關(guān)系的

public partial class weathers : System.Web.UI.Page
{
WeatherWebService weatherClass = new WeatherWebService();
protected void Page_Load(object sender, EventArgs e)
{

try
{
DataSet ds = weatherClass.getSupportDataSet();
if (!IsPostBack)
{
DataTable dt = ds.Tables[0];
DropDownList1.DataSource = dt;
DropDownList1.DataValueField = "ID";
DropDownList1.DataTextField = "Zone";
DropDownList1.DataBind();
DropDownList2.SelectedIndex = 1;
CityDataBind("1");
GetWeatherByCode("58367");
}
}
catch (Exception exp)
{

Console.WriteLine("Error"); ;
}
}
protected void CityDataBind(string zoneID)
{
DataView dv = new DataView(weatherClass.getSupportDataSet().Tables[1]);
dv.RowFilter = "[ZoneID]=" + zoneID;
DropDownList2.DataSource = dv;
DropDownList2.DataTextField = "Area";
DropDownList2.DataValueField = "AreaCode";
DropDownList2.DataBind();
DropDownList2.Items.Insert(0, new ListItem("選擇城市", "0"));
DropDownList2.SelectedIndex = 0;
}
protected void GetWeatherByCode(string cityCode)
{
String[] wa = weatherClass.getWeatherbyCityName(cityCode.Trim());
Label9.Text = wa[10];
Label1.Text = wa[6] + "   " + wa[5] + "   " + wa[7];
Label4.Text = wa[13] + "   " + wa[12] + "   " + wa[14];
Label5.Text = wa[18] + "   " + wa[17] + "   " + wa[19];
Label3.Text = wa[11].Replace("\n", "<br/>");
Label6.Text = wa[22].Replace("\n", "<br/>");
Label8.Text = DateTime.Parse(wa[4]).ToString("yyyy年MM月dd日 HH:mm");
Label7.Text = wa[0] + "/" + wa[1];
Image2.ImageUrl = "~/img/weather/" + wa[8];
Image3.ImageUrl = "~/img/weather/" + wa[9];
Image4.ImageUrl = "~/img/weather/" + wa[15];
Image5.ImageUrl = "~/img/weather/" + wa[16];
Image6.ImageUrl = "~/img/weather/" + wa[20];
Image7.ImageUrl = "~/img/weather/" + wa[21];
Image1.ImageUrl = "
Image1.AlternateText = DropDownList2.SelectedItem.Text;
}

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
CityDataBind(DropDownList1.SelectedItem.Value.Trim());
}

protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList2.Items[0].Value == "0")
{
DropDownList2.Items.RemoveAt(0);
}
GetWeatherByCode(DropDownList2.SelectedItem.Value.Trim());
}
}

好的,這里就實(shí)驗(yàn)成功了。調(diào)試運(yùn)行一下,一定成功了吧!截圖如下:


注:這里需要注意的是中間的一些圖片需要自己加到解決方案里去。

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Wizard控件的使用
FormView顯示、更新、插入、刪除數(shù)據(jù)庫(kù)操作[ASP.NET源代碼](一)
[jQuery]使用jQuery.Validate進(jìn)行客戶端驗(yàn)證(高級(jí)篇
ASP.net文章管理系統(tǒng):系統(tǒng)設(shè)計(jì)與編碼(上)
ASP.NET下備份與還原數(shù)據(jù)庫(kù)代碼
ASP.NET注冊(cè)、跳轉(zhuǎn)以及后臺(tái)腳本注冊(cè)問(wèn)題
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服