//For Register Site protected void btnSubmit_Click(object sender, EventArgs e) { lblResult.Text = ""; if (val.isValidNumber(txtSiteID.Text) && !string.IsNullOrWhiteSpace(txtDescription.Text) && !string.IsNullOrWhiteSpace(txtAPIKey.Text) && val.hasEmailTraits(txtEmailAddress.Text) && !string.IsNullOrWhiteSpace(txtEmailAddress.Text) && !string.IsNullOrWhiteSpace(txtPhoneNumber.Text)) { Site site = new Site(); site.SiteID = txtSiteID.Text; site.Description = txtDescription.Text; site.APIKey = txtAPIKey.Text; site.Email = txtEmailAddress.Text; site.PhoneNumber = txtPhoneNumber.Text; site.PhoneNumber = txtPhoneNumber.Text; try { // Setup an HTTP POST Web Request and get the HTTP Web Response from the server WebRequest request = WebRequest.Create(url + "Reg/" + site.SiteID + "/" + site.Description + "/" + site.APIKey + "/" + site.Email + "/" + site.PhoneNumber); bool data = api.RegisterSite(url, site.SiteID, site.Description, site.APIKey, site.Email, site.PhoneNumber); if (data == true) { lblResult.Text = "True"; txtSiteID.Text = ""; txtDescription.Text = ""; txtAPIKey.Text = ""; txtEmailAddress.Text = ""; txtPhoneNumber.Text = ""; } else { lblResult.Text = "False"; } } catch (Exception ex) { lblResult.Text = "Error: " + ex.Message; } } else { if (!val.isValidNumber(txtSiteID.Text) || string.IsNullOrWhiteSpace(txtSiteID.Text)) { lblResult.Text += "<br>You entered an invalid Site ID. Numbers only."; } if (!val.hasLettersorWhiteSpaceOnly(txtDescription.Text) || string.IsNullOrWhiteSpace(txtDescription.Text)) { lblResult.Text += "<br>You entered an invalid Description."; } if (string.IsNullOrWhiteSpace(txtAPIKey.Text)) { lblResult.Text += "<br>You entered an invalid APIKey. It should include numbers or letters only."; } if (string.IsNullOrWhiteSpace(txtEmailAddress.Text)) { lblResult.Text += "<br>You entered an invalid Email Address."; } if (string.IsNullOrWhiteSpace(txtPhoneNumber.Text)) { lblResult.Text += "<br>You entered an invalid Phone Number. 10-digit numbers only."; } } }