ASP.NET使用WEB SERVICE获取天气预报
引用了web服务,命名为obj,然后下面是根据书上代码改了一下,但我运行总是有错,哪位高手帮我调试一下,到底错在哪里?(项目名称BYSJ)usingSystem;usin...
引用了web服务,命名为obj,然后下面是根据书上代码改了一下,但我运行总是有错,哪位高手帮我调试一下,到底错在哪里?(项目名称BYSJ)
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 System.Web.Services;
using BYSJ.obj;
namespace BYSJ
{
public partial class Weather : System.Web.UI.Page
{
obj.WeatherWebService myobj = new obj.WeatherWebService();
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();
string fengxaing = mystr[4];
Label4.Text = "风力:" + Convert.ToString(fengxaing);
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();
}
}
}
报错:当前上下文中不存在名称"theDayFlagEnum” 展开
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 System.Web.Services;
using BYSJ.obj;
namespace BYSJ
{
public partial class Weather : System.Web.UI.Page
{
obj.WeatherWebService myobj = new obj.WeatherWebService();
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();
string fengxaing = mystr[4];
Label4.Text = "风力:" + Convert.ToString(fengxaing);
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();
}
}
}
报错:当前上下文中不存在名称"theDayFlagEnum” 展开
若以下回答无法解决问题,邀请你更新回答
3个回答
展开全部
theDayFlagEnum 这个枚举在哪里定义的? 应该是定义它的代码你没抄到项目里...
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
theDayFlagEnum 这个枚举在哪里定义的? 应该是定义它的代码你没抄到项目里...
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你这个是WEBSERVICE项目吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询