protected void showDetailsButton_Click(object sender, EventArgs e) { string voterId = voterIdTextBox.Text; WebClient webClient = new WebClient(); var data = webClient.DownloadString("http://nerdcastlebd.com/web_service/voterdb/index.php/voters/all/format/json"); JObject jObject = JObject.Parse(data); foreach (var person in jObject["voters"]) { VoterModel voterModel = new VoterModel(); voterModel.ID = person["id"].ToString(); voterModel.Name = person["name"].ToString(); voterModel.Address = person["address"].ToString(); voterModel.DateOfBirth = person["date_of_birth"].ToString(); int currentyear = DateTime.Now.Year; if (voterId == voterModel.ID) { voterIdTextBox.Text = voterModel.ID; nameTextBox.Text = voterModel.Name; addressTextBox.Text = voterModel.Address; string[] birthyear = voterModel.DateOfBirth.Split('-'); int birthyear1 = int.Parse(birthyear[0]); ageTextBox.Text = (currentyear - birthyear1).ToString(); } } string voter = voterIdTextBox.Text; if (manager.IsPatientAlreadyExists(voter)) { int serviceGiven = manager.GetServiceGivenByVoterId(voter); serviceGivenTextBox.Text = Convert.ToString(serviceGiven); } else { serviceGivenTextBox.Text = "0"; } }