ASP.net(c#)打造24小时天气预报及实时天气
2024-07-10 12:40:29
供稿:网友
本文详细介绍关于ASP.NET的实时天气及24小时天气预报
修改其中的url获得其他城市的天气情况的文章专题。
ASP.NET的实时天气及24小时天气预报(C#)
修改其中的url获得其他城市的天气情况
如广州为:
http://weather.yahoo.com
/forecast/CHXX0037_c.html
注意仅适用于获得yahoo上的天气预报
GetWeather.aspx
-----------------------------------
代码如下:<%@ Page language="c#" Codebehind="GetWeather.aspx.cs" AutoEventWireup="false" Inherits="test.GetWeather" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>GetWeather</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="GetWeather" method="post" runat="server">
<FONT face="宋体">
<P>
<asp:Label id="lblWeather" runat="server">Weather</asp:Label></P>
<P>
<asp:Button id="btnGet" runat="server" Text="Get Weather">
</asp:Button></P>
<P>
<asp:Label id="Weather2" runat="server">24小时天气</asp:Label></P>
<P>
<asp:Button id="btnGet2" runat="server" Text="天气预报">
</asp:Button></P>
</FONT>
</form>
</body>
</HTML>
getWeather.aspx.cs
---------------------------------------
代码如下:using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Net;
using System.IO;
namespace test
{
public class GetWeather : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblWeather;