protected void searchButton_OnServerClick(object sender, EventArgs e) { Patient patient = new Patient(); string billNo = billNoTextBox.Value; string mobileNumber = mobileNoTextBox.Value; string message = ""; if ((billNo.Trim().Length == 0 && mobileNumber.Trim().Length == 0) || (billNo.Trim().Length > 0 && mobileNumber.Trim().Length > 0)) { message = "Either Bill No or Mobile No Should be Filled."; } else if (billNo.ToString().Trim().Length > 0) { patient = billManager.GetBillInfoByBillNo(Convert.ToInt32(billNoTextBox.Value)); } else { patient = billManager.GetBillInfoByMobileNo(mobileNumber); } if (patient == null) { message = "Patient with entered Bill No. or Mobile No. does not exists."; } else { dueDateTextBox.Value = patient.DueDate.ToString(); amountTextBox.Value = patient.TotalFee.ToString(); ViewState["Patient"] = patient; } messageLabel.Text = message; }