protected void txtZipCode_TextChanged(object sender, EventArgs e) { if (this.txtZipCode.Text != "") { SalitaEntities db = new SalitaEntities(); ListZip z = db.ListZips.SingleOrDefault(p => p.ZipCode == this.txtZipCode.Text); if (z != null) { this.txtTown.Value = z.City; } } }
protected void txtZipCode_TextChanged(object sender, EventArgs e) { try { if (this.txtZipCode.Text != "") { SalitaEntities db = new SalitaEntities(); ListZip z = db.ListZips.SingleOrDefault(p => p.ZipCode == this.txtZipCode.Text); if (z != null) { this.txtTown.Text = z.City; } } } catch (Exception E) { this.CustomValidator1.IsValid = false; this.CustomValidator1.ErrorMessage = E.Message; } }