protected void Submit_Click(object sender, EventArgs e) { if (Page.IsValid) { var WeatherList = WeatherData.CallApi(Zipcode.Text); if (WeatherList == null) { ErrorMessage.Text = "Error, a problem occured."; Location.Text = ""; Temp.Text = ""; Humidity.Text = ""; TempMax.Text = ""; TempMin.Text = ""; Pressure.Text = ""; WindSpeed.Text = ""; } else { Location.Text = "Location: " + WeatherList["Location Name"]; Temp.Text = "Temperature: " + WeatherList["Temperature"]; Humidity.Text = "Humidity: " + WeatherList["Humidity"]; TempMax.Text = "Temperature Max: " + WeatherList["Temperature Max"]; TempMin.Text = "Temperature Min: " + WeatherList["Temperature Min"]; Pressure.Text = "Pressure: " + WeatherList["Pressure"]; WindSpeed.Text = "Windspeed: " + WeatherList["Wind Speed"]; } } }
protected void zipButton_Click(object sender, EventArgs e) { string checkIfValidZip = zipInput.Text; if (IsPostBack && Page.IsValid) { errorMessage.Text = ""; Dictionary <string, string> theWeather = WeatherData.CallApi(checkIfValidZip); temp.Text = temp.Text + theWeather["Temperature"]; temp_min.Text = "Temperature Minumum: " + theWeather["Temperature Min"]; temp_max.Text = "Temperature Maximum: " + theWeather["Temperature Max"]; pressure.Text = "Presure: " + theWeather["Pressure"]; humidity.Text = "Humidity: " + theWeather["Humidity"]; wind_speed.Text = "Wind Speed" + theWeather["Temperature Max"]; } }
protected void Submit_Click(object sender, EventArgs e) { if (Page.IsValid) { string zipCode = ZipCode.Text; Dictionary <string, string> weatherData = WeatherData.CallApi(zipCode); if (weatherData != null) { WeatherDataLabel.Visible = false; WeatherDataRepeater.Visible = true; WeatherDataRepeater.DataSource = weatherData; WeatherDataRepeater.DataBind(); } else { WeatherDataLabel.Visible = true; WeatherDataLabel.Text = WeatherDataErrorMessage; WeatherDataRepeater.Visible = false; } } }
protected void GetWeather_Click(object sender, EventArgs e) { if (Page.IsValid) { string zip = Zip.Text; Dictionary <string, string> data = WeatherData.CallApi(zip); if (data != null) { WeatherInformation.Visible = true; Error.Visible = false; WeatherInformation.DataSource = data; WeatherInformation.DataBind(); } else { WeatherInformation.Visible = false; Error.Visible = true; } } }