protected void txtCustomStudentId_TextChanged(object sender, EventArgs e) { StudentBO studentBO = new StudentBO(); StudentMajorBO studentmajorBO = new StudentMajorBO(); int studentId = 0; if (txtCustomStudentId.Text.Trim() != "") { try { studentId = int.Parse(txtCustomStudentId.Text.Trim()); string studentName = studentBO.GetStudentNameForId(studentId); if (studentName != "") { List <StudentMajorVO> stmajorList = studentmajorBO.GetStudentMajorList(studentId); string major = ""; foreach (StudentMajorVO studentMajorVO in stmajorList) { major += "&" + studentMajorVO.MajorID; } if (major.StartsWith("&")) { major = major.Substring(1); } txtStudentMajor.Text = major; ddMajor.Enabled = false; txtStudentId.Text = studentId.ToString(); } txtName.Text = studentName; if (studentName == "") { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert(' Please enter a valid student id');", true); // Response.Write("<script>alert(' Please enter a valid student id ');</script>"); return; } else { FillTemplateNameDropDown(); } } catch (ParseException) { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert(' Please enter a valid student id ');", true); //Response.Write("<script>alert(' Please enter a valid student id ');</script>"); } catch (Exception ex) { Response.Write("<script>alert(' Error in getting student details ');</script>"); ExceptionUtility.LogException(ex, "Error Page"); } } else { txtStudentId.Text = ""; txtName.Text = ""; } }
protected void txtStudentId_TextChanged(object sender, EventArgs e) { StudentBO studentBO = new StudentBO(); int studentId = 0; if (txtStudentId.Text.Trim() != "") { try { studentId = int.Parse(txtStudentId.Text.Trim()); string studentName = studentBO.GetStudentNameForId(studentId); txtName.Text = studentName; if (studentName == "") { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert(' Please enter a valid student id ');", true); // Response.Write("<script>alert(' Please enter a valid student id ');</script>"); } } catch (ParseException) { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert(' Please enter a valid student id ');", true); //Response.Write("<script>alert(' Please enter a valid student id ');</script>"); } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert(' Error in getting student details ');", true); //Response.Write("<script>alert(' Error in getting student details ');</script>"); ExceptionUtility.LogException(ex, "Error Page"); } } else { txtStudentId.Text = ""; txtName.Text = ""; } }