C # WebServices with weather forecasts,
Background code:
- Protected void Page_Load (object sender, EventArgs e)
- {
- If (! IsPostBack)
- {
- WeatherWS ws = new WeatherWS ();
- IList <string> provinceDataSource = new List <string> ();
- DataSet proDs = ws. getRegionDataset ();
- DdlProvince. DataSource = proDs. Tables [0]. DefaultView;
- DdlProvince. DataTextField = "RegionName ";
- DdlProvince. DataValueField = "RegionID ";
- DdlProvince. DataBind ();
- }
- }
- Protected void button#click (object sender, EventArgs e)
- {
- WeatherWS ws = new WeatherWS ();
- String [] wsInfo = ws. getWeather (ddlCity. SelectedValue ,"");
- String result = string. Empty;
- For (int I = 0; I <wsInfo. Length; I ++)
- {
- Result + = wsInfo [I] + "<BR/> ";
- }
- Label1.Text = result;
- }
- Protected void ddlProvince_SelectedIndexChanged (object sender, EventArgs e)
- {
- WeatherWS ws = new WeatherWS ();
- DataSet cityDs = ws. getSupportCityDataset (ddlProvince. SelectedValue );
- DdlCity. DataSource = cityDs. Tables [0]. DefaultView;
- DdlCity. DataTextField = "CityName ";
- DdlCity. DataValueField = "CityID ";
- DdlCity. DataBind ();
- }
. Aspx code
- <Asp: UpdatePanel ID = "UpdatePanel1" runat = "server">
- <ContentTemplate>
- <Asp: DropDownList ID = "ddlProvince" runat = "server" AutoPostBack = "True"
- Onselectedindexchanged = "ddlProvince_SelectedIndexChanged">
- </Asp: DropDownList>
- <Asp: DropDownList ID = "ddlCity" runat = "server">
- </Asp: DropDownList>
- <Asp: Button ID = "Button1" runat = "server" onclick = "button#click" Text = "Button"/>
- <Br/>
- <Br/>
- <Br/>
- <Asp: Label ID = "Label1" runat = "server" Text = "Label"> </asp: Label>
- </ContentTemplate>
- </Asp: UpdatePanel>
Slow access ,,,...
Step 1 Add a Web reference
Then there is something on the page... webServices clearly