private bool IsDataValidOnSave() { bool isValid = true; bool isSessionLive = true; StringBuilder script = new StringBuilder(); //if (Commons.GetCurrentLoginUser() == null) //{ // script.Append("Session is expired!"); // isSessionLive = false; //} if (txtNik.Text == "") { script.Append("NIK has to be filled!"); txtNik.Focus(); } else if (txtNameEmployee.Text == "") { script.Append("NameEmployee has to be filled!"); txtNameEmployee.Focus(); } else if (lblNamePhoto.Text == "") { script.Append("Upload Photo has to be filled!"); FileUpload_Photo.Focus(); } if (script.Length > 0) { isValid = false; if (isSessionLive) { ScriptManager.RegisterStartupScript(this.Page, typeof(String), "Validation", "alert('" + script.ToString() + "');", true); } else { ScriptManager.RegisterStartupScript(this.Page, typeof(String), "Validation", "alert('" + script.ToString() + "');window.close();", true); } } script = null; return(isValid); }