当前位置:编程学习 > C#/ASP.NET >>

asp.net天气预报显示

如何引用web 实现天气预报显示网页代码!!


 cn.com.webxml.webservice.WeatherWS ws = new cn.com.webxml.webservice.WeatherWS();
        try
        {
            
        }
        catch
        { 
        
        }

这不之后怎么实现呢? --------------------编程问答-------------------- 以前写的,仅供参考

protected void Page_Load(object sender, EventArgs e)
     {
         if (!IsPostBack)
         {
             ipaddress.IpAddressSearchWebService web = new ipaddress.IpAddressSearchWebService();
             string str = "";
             str = web.getCountryCityByIp(Request.UserHostAddress.Trim())[1];
             if (str.Contains("省"))
             {
                 str = str.Split('省').Last();
             }
             str = str.Split(' ').First();
             str = str.Replace("市", "");
             findweather(str);
         }
     }
     public void findweather(string city)
     {
         weather.WeatherWebService p = new WeatherWebService();
         string[] str = p.getWeatherbyCityName(city);
         citylabel.Text = city;
         img1.Src = "image\\weather\\b_" + str[8].Trim();
         wendu.Text = str[5].Replace("/", "~");
         tianqi.Text = str[6].Split(' ').Where(t => t.Trim() != "").Last();
     } --------------------编程问答-------------------- 参考 http://blog.csdn.net/c979170768/article/details/7082622 --------------------编程问答-------------------- public partial class _Default : System.Web.UI.Page 
{
    obj.Service myobj = new obj.Service(); //实例化
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            BindPro();
            BindCity();
            BindWeather();
        }
    }
    // 获得省份
    protected void BindPro()
    {
        string [] pro=myobj.getSupportProvince();
        for (int i = 1; i <= Int32 .Parse (pro[0]); i++)
        {
            DropDownList1.Items.Add(new ListItem (pro[i].ToString (),pro[i].ToString()));
        }
    }
    //获得城市
    protected void BindCity()
    {
        DropDownList2.Items.Clear();
        string[] city = myobj.getSupportCity (DropDownList1 .SelectedValue );
        for (int i = 1; i <= Int32.Parse(city[0]); i++)
        {
            DropDownList2.Items.Add(new ListItem(city[i].ToString(), city[i].ToString()));
        }
    }
    //天气预报
    protected void BindWeather()
    {
        string[] mystr = myobj.getWeatherbyCityName(DropDownList2 .SelectedValue , theDayFlagEnum.Today);
        Label1.Text = mystr[1].ToString();
        Label2.Text = mystr[2].ToString();
        Label3.Text = mystr[3].ToString();
        Label4.Text = mystr[4].ToString();
        Label5.Text = mystr[5].ToString();
        Image1.ImageUrl = mystr[6].ToString();
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        BindCity();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        BindWeather();
    }
}
--------------------编程问答-------------------- 调用ws对象里的方法,看看都有什么就知道了。。看方法名字很明显的。 --------------------编程问答-------------------- 实现数据,得到数据,分析,显示啊,接口一般返回数组,你分析数组就可以了 --------------------编程问答-------------------- 有很多天气预报插件的。自己写多麻烦……
http://www.tianqi.com/index.php?c=code&id=9 
这是深圳的天气情况 --------------------编程问答-------------------- 查看实现webservice的帮助,调用别人的应用都有帮助的,好好看下, --------------------编程问答-------------------- 如只是显示的话可不用webservice。直接到相应网站上有JS代码可以调用的。 --------------------编程问答--------------------
引用 2 楼 conan8126 的回复:
参考 http://blog.csdn.net/c979170768/article/details/7082622


兄弟,这个插件怎么弄!运行不了!
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,