protected void Button1_Click(object sender, EventArgs e) { int v1, v2, result; Label_Error.Text = ""; try { v1 = Int32.Parse(TextBox1.Text); v2 = Int32.Parse(TextBox2.Text); } catch (Exception ex) { if (ex.Message[0] == 'A') { RangeValidator2.Validate(); } else { RequiredFieldValidator2.Validate(); } return; } result = v1 / v2; TextBox3.Text = result.ToString(); Label_Error.Text = "Divide error"; }
protected void UpdateCate_Click(object sender, EventArgs e) { RequiredFieldValidator1.Validate(); RequiredFieldValidator2.Validate(); RegularExpressionValidator1.Validate(); RequiredFieldValidator3.Validate(); List <String> list = new List <string>(); list.Add(this.txtProductName.Text); list.Add(this.DropDownList3.SelectedItem.Value); list.Add(this.DropDownList2.SelectedItem.Value); list.Add(this.txtUnitPrice.Text); list.Add(this.RadioButtonList1.SelectedItem.Text); if (lblProID.Text.Equals("")) { new products().insert(list); } else { new products().update(Int32.Parse(lblProID.Text), list); } LoadProduct(); }
private bool validateall() { RequiredFieldValidator1.Validate(); RequiredFieldValidator2.Validate(); RequiredFieldValidator3.Validate(); RequiredFieldValidator4.Validate(); RequiredFieldValidator5.Validate(); RequiredFieldValidator6.Validate(); RequiredFieldValidator7.Validate(); RequiredFieldValidator8.Validate(); RequiredFieldValidator9.Validate(); RegularExpressionValidator1.Validate(); RegularExpressionValidator2.Validate(); RegularExpressionValidator3.Validate(); RegularExpressionValidator4.Validate(); RegularExpressionValidator5.Validate(); RegularExpressionValidator6.Validate(); RegularExpressionValidator7.Validate(); CompareValidator1.Validate(); CompareValidator2.Validate(); CompareValidator3.Validate(); if (!RequiredFieldValidator1.IsValid || !RequiredFieldValidator2.IsValid || !RequiredFieldValidator3.IsValid || !RequiredFieldValidator4.IsValid || !RequiredFieldValidator5.IsValid || !RequiredFieldValidator6.IsValid || !RequiredFieldValidator7.IsValid || !RequiredFieldValidator8.IsValid || !RequiredFieldValidator9.IsValid || !RegularExpressionValidator1.IsValid || !RegularExpressionValidator2.IsValid || !RegularExpressionValidator3.IsValid || !RegularExpressionValidator4.IsValid || !RegularExpressionValidator5.IsValid || !RegularExpressionValidator6.IsValid || !RegularExpressionValidator7.IsValid || !CompareValidator1.IsValid || !CompareValidator2.IsValid || !CompareValidator3.IsValid) { return(false); } return(true); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack == true) { RequiredFieldValidator2.Validate(); RegularExpressionValidator1.Validate(); string validatessn = SSN.Text; if (Application["AllUsersList"] != null) { List <StudentInfor> allUsersList = Application["AllUsersList"] as List <StudentInfor>; if (allUsersList != null) { for (int i = 0; i < allUsersList.Count; i++) { if (allUsersList[i].SocialSecurityNumber == validatessn) { RequiredFieldValidator2.Validate(); RegularExpressionValidator1.Validate(); string message = "allready exist.Please go to login page."; System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<script type = 'text/javascript'>"); sb.Append("window.onload=function(){"); sb.Append("alert('"); sb.Append(validatessn); sb.Append(message); sb.Append("')};"); sb.Append("</script>"); ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString()); SSN.Text = ""; } } } } } }
protected void Page_Load(object sender, EventArgs e) { RequiredFieldValidator1.Validate(); CompareValidator1.Validate(); RegularExpressionValidator1.Validate(); RequiredFieldValidator2.Validate(); RequiredFieldValidator3.Validate(); }
protected void AddCate_Click(object sender, EventArgs e) { RequiredFieldValidator1.Validate(); RequiredFieldValidator2.Validate(); RegularExpressionValidator1.Validate(); RequiredFieldValidator3.Validate(); AddProduct(); LoadProduct(); }
protected void button2_click(object sender, EventArgs e) { RequiredFieldValidator1.Validate(); RequiredFieldValidator2.Validate(); if (!RequiredFieldValidator2.IsValid || !RequiredFieldValidator1.IsValid) { if (!RequiredFieldValidator1.IsValid) TextBox1.Text = "不能为空!"; if (!RequiredFieldValidator2.IsValid) TextBox2.Text = "不能为空!"; } else { try { int i = UserIdentity.Login(TextBox1.Text,TextBox2.Text); if (i == 1) { if (UserIdentity.IsInRole(UserIdentity.Role.Admin)) eMessage.Message("登录成功,欢迎您回来!", "./Teacher/usermanage.aspx"); eMessage.Message("登录成功,欢迎您回来!", "./subjectdescribe.aspx"); } else if (i == 0) { eMessage.Message("您的帐号还未通过验证,请联系老师!", "./subjectdescribe.aspx"); } else if (i == -1) { eMessage.Message("用户名或密码错误,登录失败!", "./subjectdescribe.aspx"); } } catch (Exception err) { eMessage.Message(err); eMessage.Message(err.Message, "./subjectdescribe.aspx"); } finally { } } }
protected void btAdd_Click(object sender, EventArgs e) { RequiredFieldValidator1.Validate(); RequiredFieldValidator2.Validate(); RequiredFieldValidator3.Validate(); if (!RequiredFieldValidator3.IsValid || !RequiredFieldValidator2.IsValid || !RequiredFieldValidator1.IsValid) { eMessage.Message("请填写完整信息!", UpdatePanel1, this); } else { SqlConnection con = new SqlConnection(DealData.constring); SqlCommand cmd = new SqlCommand("usp_InsertNews", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@Title", SqlDbType.NVarChar, 50)).Value = HttpUtility.HtmlEncode(txtTitle.Text); cmd.Parameters.Add(new SqlParameter("@Content", SqlDbType.NText)).Value = HttpUtility.HtmlEncode(txtContent.Text).Replace("\r", "<br>").Replace(" ", " "); cmd.Parameters.Add(new SqlParameter("@DeleteTime", SqlDbType.DateTime)).Value = Convert.ToDateTime(txtDeleteTime.Text); cmd.Parameters.Add(new SqlParameter("@UserName", SqlDbType.NVarChar, 50)).Value = Session["UserName"].ToString(); try { con.Open(); if (cmd.ExecuteNonQuery() > 0) { eMessage.Message("发布成功!", UpdatePanel1, this); } } catch (SqlException err) { eMessage.Message(err); eMessage.Message("与数据库连接发生故障!详细信息:" + err.Message, UpdatePanel1, this); } finally { if (con != null) { con.Close(); } } } }
//******************************************************* // // AddEntry_Click server event handler on this page is used to // saves a time entry and adds it to the system. // //******************************************************* protected void AddEntry_Click(object sender, System.EventArgs e) { // check validation. Requiredfieldvalidator1.Validate(); RequiredFieldValidator2.Validate(); RangeValidator1.Validate(); CompareValidator1.Validate(); // proceeds if data is valid then create an obejct and save it. if (Requiredfieldvalidator1.IsValid && RequiredFieldValidator2.IsValid && CompareValidator1.IsValid && RangeValidator1.IsValid) { BusinessLogicLayer.TimeEntry te = new BusinessLogicLayer.TimeEntry(0, Convert.ToInt32(UserList.SelectedItem.Value), Convert.ToInt32(ProjectList.SelectedItem.Value), Convert.ToInt32(CategoryList.SelectedItem.Value), Convert.ToDateTime(Days.SelectedItem.Value), ITSecurity.CleanStringRegex(Description.Text), Convert.ToDecimal(Hours.Text)); te.Save(); ClearEntryFields(); } }
protected void login_B_Click(object sender, EventArgs e) { RequiredFieldValidator1.Validate(); RegularExpressionValidator1.Validate(); RequiredFieldValidator2.Validate(); RegularExpressionValidator2.Validate(); if (RequiredFieldValidator1.IsValid == false || RegularExpressionValidator1.IsValid == false || RequiredFieldValidator2.IsValid == false || RegularExpressionValidator2.IsValid == false) { return; } String email = email_T.Text; String code = password_T.Text; int current_User_Index = -1; List <User> allUsersList = Application["AllUsersList"] as List <User>; if ((Application["AllUsersList"] != null) && (current_User_Index = check_Valid_User_Login(allUsersList, email, code)) >= 0) { ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('Successpully Logged In!');", true); Session["CurrentUser"] = allUsersList[current_User_Index]; login_L1.Text = "Welcome " + allUsersList[current_User_Index].FullName + " !"; login_users.Visible = false; current_users_panel.Visible = false; new_users_panel.Visible = false; user_account_panel.Visible = true; recover_password.Visible = false; } else { ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('Unable to Login. Invalid email-id or access-code!');", true); } }
protected void btnOdemeIleri_Click(object sender, EventArgs e) { Page.Validate(); if (CreditCardNumber.Text.Length == 16 && CVC2.Text.Length == 3 && IsValid && CardOwner.Text.Length > 4 && Data.CreditCardValidation.ValidateCardNumber(CreditCardNumber.Text)) { Ay = dlistAYtmp.SelectedValue; Yil = dlistYILtmp.SelectedValue; btnIleri(); } else if (!Data.CreditCardValidation.ValidateCardNumber(CreditCardNumber.Text)) { RegularExpressionValidator1.IsValid = false; //RegularExpressionValidator1.ErrorMessage = "Test Başarısız"; RegularExpressionValidator1.Text = "Test Başarısız"; } else { RequiredFieldValidator1.Validate(); RequiredFieldValidator2.Validate(); RequiredFieldValidator3.Validate(); } }
protected void BtReg_Click(object sender, EventArgs e) { RequiredFieldValidator1.Validate(); RequiredFieldValidator2.Validate(); RequiredFieldValidator3.Validate(); RequiredFieldValidator4.Validate(); RequiredFieldValidator5.Validate(); RequiredFieldValidator6.Validate(); RequiredFieldValidator7.Validate(); CompareValidator1.Validate(); RegularExpressionValidator1.Validate(); RegularExpressionValidator2.Validate(); RegularExpressionValidator3.Validate(); RequiredFieldValidator8.Validate(); RequiredFieldValidator9.Validate(); if (!RequiredFieldValidator8.IsValid || !RequiredFieldValidator9.IsValid || !RequiredFieldValidator1.IsValid || !RequiredFieldValidator2.IsValid || !RequiredFieldValidator3.IsValid || !RequiredFieldValidator4.IsValid || !RequiredFieldValidator5.IsValid || !RequiredFieldValidator6.IsValid || !RequiredFieldValidator7.IsValid || !CompareValidator1.IsValid || !RegularExpressionValidator1.IsValid || !RegularExpressionValidator2.IsValid || !RegularExpressionValidator3.IsValid) { eMessage.Message("请仔细检查输入!", UpdatePanel1, this); return; } if (!this.SerialNumber1.CheckSN(txtCheck.Text) || txtCheck.Text == null || txtCheck.Text == "") { eMessage.Message("请输入正确的验证码", UpdatePanel1, this); this.SerialNumber1.Create(); return; } if (!Regex.IsMatch(txtIdReg.Text, "^\\d{10}$")) { eMessage.Message("不正确的ID", UpdatePanel1, this); SerialNumber1.Create(); return; } if (!Regex.IsMatch(txtNameReg.Text, "^[\u4E00-\u9FA5]{0,}$")) { eMessage.Message("请输入正确的姓名", UpdatePanel1, this); SerialNumber1.Create(); return; } if (txtPawReg.Text != txtPawRegCnf.Text) { eMessage.Message("您两次输入的密码不同", UpdatePanel1, this); SerialNumber1.Create(); return; } var cn = new SqlConnection(); cn.ConnectionString = DealData.constring; SqlCommand cmd = new SqlCommand("usp_VaUserName", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@username", SqlDbType.NVarChar, 50)).Value = txtUsrReg.Text; try { cn.Open(); if ((string)cmd.ExecuteScalar() != null) { eMessage.Message("该用户名已被注册!", UpdatePanel1, this); SerialNumber1.Create(); return; } } catch (Exception e1) { eMessage.Message("系统发生问题,请稍后重试或联系管理员", UpdatePanel1, this); SerialNumber1.Create(); eMessage.Message(e1); } finally { cn.Close(); } int state = 0; var cn2 = new SqlConnection(); cn2.ConnectionString = DealData.constring; SqlCommand cmd2 = new SqlCommand("usp_CreateUser", cn2); cmd2.CommandType = CommandType.StoredProcedure; cmd2.Parameters.Add(new SqlParameter("@username", SqlDbType.NVarChar, 50)).Value = txtUsrReg.Text; cmd2.Parameters.Add(new SqlParameter("@studentid", SqlDbType.NVarChar, 50)).Value = txtIdReg.Text; cmd2.Parameters.Add(new SqlParameter("@password", SqlDbType.NVarChar, 50)).Value = txtPawReg.Text; cmd2.Parameters.Add(new SqlParameter("@email", SqlDbType.NVarChar, 50)).Value = txtEmailReg.Text; cmd2.Parameters.Add(new SqlParameter("@question", SqlDbType.NVarChar, 50)).Value = txtQueReg.Text; cmd2.Parameters.Add(new SqlParameter("@key", SqlDbType.NVarChar, 50)).Value = txtAnsReg.Text; cmd2.Parameters.Add(new SqlParameter("@RealName", SqlDbType.NVarChar, 50)).Value = txtNameReg.Text; try { cn2.Open(); if (cmd2.ExecuteNonQuery() > 0) { eMessage.Message("注册成功,请等待老师的审核!", UpdatePanel1, this); SerialNumber1.Create(); state = 1; } else { eMessage.Message("注册失败,请稍后再试", UpdatePanel1, this); SerialNumber1.Create(); state = -1; } } catch (Exception e2) { eMessage.Message("系统发生错误请稍后再试", UpdatePanel1, this); SerialNumber1.Create(); eMessage.Message(e2); } finally { cn2.Close(); if (state == 1) { Response.Redirect("~/Default.aspx"); } } }