Exemple #1
0
        protected void customValidator_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["UserdbConnectionString"].ConnectionString);

            conn.Open();
            string     correctpw = "select Password from UserTable where Email='" + Email.Text + "'";
            SqlCommand cmds      = new SqlCommand(correctpw, conn);



            try
            {
                string checkpw = cmds.ExecuteScalar().ToString().Trim();


                string pass = Password.Text;
                bool   flag = Hash.VerifyHash(pass, "SHA512", checkpw);
                if (flag == false)
                {
                    customValidator1.ErrorMessage = " Wrong login Credentials";
                    args.IsValid = false;
                }
            }
            catch (Exception s)
            {
                Debug.WriteLine(s);
                customValidator1.ErrorMessage = "Email does not exist ";
                args.IsValid = false;
            }
        }
Exemple #2
0
        protected void CustomValidator1_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            DateTime DOB;

            DateTime.TryParse(dob.ToString(), out DOB);
            args.IsValid = ((DateTime.Today.Year - DOB.Year) < 18);
        }
Exemple #3
0
        protected void CustomValidatorFecha_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            DateTime txtMyDateInicio = DateTime.Parse(txtFechaInicio.Text);
            DateTime txtMyDateFin    = DateTime.Parse(txtFechaFin.Text);

            args.IsValid = (txtMyDateFin - txtMyDateInicio).TotalDays < 90;
        }
        protected void CustomValidator1_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            args.IsValid = true;
            System.IO.StringReader sw = new System.IO.StringReader(ImportField.Text);
            string splitCharacter     = ",";
            string lineToProcess      = string.Empty;

            lineToProcess = sw.ReadLine();

            while (lineToProcess != null)
            {
                string[] lineValues = lineToProcess.Split(splitCharacter.ToCharArray());
                if (lineValues.Length > 0)
                {
                    string EmailAddress = lineValues[0];
                    System.Text.RegularExpressions.Regex re
                        = new System.Text.RegularExpressions.Regex("\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*",
                                                                   System.Text.RegularExpressions.RegexOptions.Compiled);
                    if (re.Match(EmailAddress).Value != EmailAddress)
                    {
                        args.IsValid = false;
                        return;
                    }
                }
                lineToProcess = sw.ReadLine();
            }
            sw.Dispose();
        }
Exemple #5
0
        protected void vldCommand_ServerValidate(Object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            var msg = "";

            args.IsValid            = Convert.ToBoolean(Services.Data.Query.IsQueryValid(txtCommand.Text, ConnectionController.GetConnectionString(Convert.ToInt32(cpConnection.ConnectionId), ReportSetId), ref msg));
            vldCommand.ErrorMessage = msg;
        }
 protected void CvUserEmail_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
 {
     if (txtEmail.Text == "admin" || !myUniversityDB.IsUnique("Student", "email", txtEmail.Text))
     {
         args.IsValid = false;
     }
 }
Exemple #7
0
 protected void CustomValidator1_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
 {
     if (!this.check_Acepto.Checked)
     {
         args.IsValid = false;
     }
 }
        protected void ProductTypeCustomValidator_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            List <ProductProperty> props = MTApp.CatalogServices.ProductPropertiesFindForType(lstProductType.SelectedValue);

            for (int i = 0; i <= (ProductTypeProperties.Count - 1); i++)
            {
                switch (props[i].TypeCode)
                {
                case ProductPropertyType.CurrencyField:
                    decimal temp;
                    if (!decimal.TryParse(ProductTypeProperties[i], out temp))
                    {
                        args.IsValid = false;
                        ProductTypeCustomValidator.ErrorMessage = props[i].DisplayName + " must be a valid monetary type.";
                        return;
                    }
                    break;

                case ProductPropertyType.DateField:
                    DateTime temp2;
                    if (!System.DateTime.TryParse(ProductTypeProperties[i], out temp2))
                    {
                        args.IsValid = false;
                        ProductTypeCustomValidator.ErrorMessage = props[i].DisplayName + " must be a valid date.";
                        return;
                    }
                    break;

                case ProductPropertyType.MultipleChoiceField:
                    break;
                }
            }
        }
        private void cvCaptcha_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            SharedBasePage requestPage = Page as SharedBasePage;

            if (CaptchaControl1.Enabled && requestPage.SiteConfig.EnableCaptcha)
            {
                args.IsValid = CaptchaControl1.UserValidated;
            }
        }
Exemple #10
0
        protected void UsernameValidator_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            string username = args.Value;

            if (!Regex.IsMatch(username, @"^[a-zA-Z0-9_-]{3,15}$"))
            {
                UsernameValidator.ErrorMessage = "Username must contain letters, digits and '-' and '_', and its length must be between 3 to 15 characters.";
                args.IsValid = false;
            }
        }
 protected void CvStudentId_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
 {
     if (IsValid)
     {
         if (!myUniversityDB.IsUnique("Student", "studentId", txtStudentId.Text))
         {
             args.IsValid = false;
         }
     }
 }
Exemple #12
0
        protected void PasswordValidator_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            string password = args.Value;

            if (!Regex.IsMatch(password, @"^[a-zA-Z0-9]{8,}$"))
            {
                PasswordValidator.ErrorMessage = "Password can contain only letters and digits and its length must be at least 8 characters.";
                args.IsValid = false;
            }
        }
Exemple #13
0
        protected void UrlValidator_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            string pattern = @"(http|https):\/\/[\w\-_]+(\.[\w-_]+)?([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?";
            Regex  reg     = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);

            if (!reg.IsMatch(txtDestination.Text))
            {
                args.IsValid = false;
            }
        }
Exemple #14
0
        protected void valNoPipesInTitle_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            var text = args.Value;

            if (text.Contains('|'))
            {
                args.IsValid = false;
                return;
            }
            args.IsValid = true;
        }
Exemple #15
0
 protected void CustomValidatorUserLogin_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
 {
     if (LoginSucces())
     {
         args.IsValid = true;
     }
     else
     {
         args.IsValid = false;
     }
 }
 protected void valNameLength_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
 {
     if ((this.productnamefield.Text.Trim().Length > 255))
     {
         args.IsValid = false;
     }
     else
     {
         args.IsValid = true;
     }
 }
        /// <summary>
        /// Handles the OnServerValidate event of the CustomValidator control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="args">The <see cref="System.Web.UI.WebControls.ServerValidateEventArgs"/> instance containing the event data.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="args" /> is null.</exception>
        protected void cv_OnServerValidate(object sender, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            int albumId;

            args.IsValid = ((tv.SelectedNode != null) && Int32.TryParse(tv.SelectedNode.Value, out albumId) && (albumId > int.MinValue));
        }
 protected void valSkuLength_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
 {
     if ((this.SkuField.Text.Trim().Length > 50))
     {
         args.IsValid = false;
     }
     else
     {
         args.IsValid = true;
     }
 }
Exemple #19
0
        protected void CustomValidator1_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            try
            {
                args.IsValid = Convert.ToDouble(TextBox1.Text) > 0;
            }

            catch
            {
                args.IsValid = false;
            }
        }
Exemple #20
0
        protected void CustomValidator1_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            string senha = args.Value;

            if (senha.Length >= 5 && senha.Length <= 10)
            {
                args.IsValid = true;
            }
            else
            {
                args.IsValid = false;
            }
        }
        protected void IsMonetary_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            decimal val = 0m;

            if (decimal.TryParse(args.Value, System.Globalization.NumberStyles.Currency, System.Threading.Thread.CurrentThread.CurrentUICulture, out val))
            {
                args.IsValid = true;
            }
            else
            {
                args.IsValid = false;
            }
        }
Exemple #22
0
 protected void cvAccountNumber_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
 {
     if (AccountNumber.Text != null && LastName.Text != null)
     {
         string accountnumber = AccountNumber.Text;
         string lastname      = LastName.Text.ToUpper();
         Int32  test;
         if (accountnumber.Length == 10)
         {
             if ((!Int32.TryParse(accountnumber.Substring(2), out test)))
             {
                 args.IsValid = false;
                 cvAccountNumber.ErrorMessage = "The format of account number is not correct.";
             }
         }
         else
         {
             args.IsValid = false;
         }
         if (lastname.Length == 1)
         {
             if (accountnumber[0] != lastname[0])
             {
                 args.IsValid = false;
             }
             if (accountnumber[1] != lastname[0])
             {
                 args.IsValid = false;
             }
             if (args.IsValid == false)
             {
                 cvAccountNumber.ErrorMessage = "The account number does not match the client's last name.";
             }
         }
         else if (lastname.Length > 1)
         {
             if (accountnumber[0] != lastname[0])
             {
                 args.IsValid = false;
             }
             if (accountnumber[1] != lastname[1])
             {
                 args.IsValid = false;
             }
             if (args.IsValid == false)
             {
                 cvAccountNumber.ErrorMessage = "The account number does not match the client's last name.";
             }
         }
     }
 }
        protected void DateCustomValidator_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            DateTime temp;

            if (System.DateTime.TryParse(args.Value,
                                         System.Threading.Thread.CurrentThread.CurrentUICulture,
                                         System.Globalization.DateTimeStyles.None, out temp))
            {
                args.IsValid = true;
            }
            else
            {
                args.IsValid = false;
            }
        }
Exemple #24
0
        protected void cvAccountNumber_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            string accountNumber = AccountNumber.Text.Trim();
            string lastName      = LastName.Text.Trim();

            lastName = lastName.ToUpper();
            int index = 2;

            if (accountNumber.Length != 10)
            {
                args.IsValid = false;
                return;
            }
            if (lastName.Length == 1)
            {
                if (accountNumber[0] != lastName[0] || accountNumber[1] != lastName[0])
                {
                    args.IsValid = false;
                    cvAccountNumber.ErrorMessage = "The account number does not match the client's last name";
                    return;
                }
            }
            else
            {
                if (accountNumber[0] != lastName[0] || accountNumber[1] != lastName[1])
                {
                    args.IsValid = false;
                    cvAccountNumber.ErrorMessage = "The account number does not match the client's last name";
                    return;
                }
            }
            if (accountNumber.Length - index != 8)
            {
                args.IsValid = false;
                return;
            }
            for (; index < accountNumber.Length; ++index)
            {
                if (!char.IsDigit(accountNumber[index]))
                {
                    args.IsValid = false;
                    return;
                }
            }

            args.IsValid = true;
            return;
        }
        protected void CvIsDuplicateUsername_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            decimal result = myConferenceDB.IsAttributeValueUnique("Person", "username", myHelpers.CleanInput(txtUsername.Text));

            if (result != 0)
            {
                if (result == -1)
                {
                    myHelpers.DisplayMessage(lblResultMessage, sqlError);
                }
                else
                {
                    cvUsername.ErrorMessage = "Duplicate username.";
                }
                args.IsValid = false;
            }
        }
 protected void CustomValidator3_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
 {
     if (rrPsdText.Text.Equals("") || rrPsdText.Text.Equals("确认密码"))
     {
         args.IsValid = false;
         CustomValidator3.ErrorMessage = "*确认密码为空";
     }
     else if (!rrPsdText.Text.Equals(rPsdText.Text))
     {
         args.IsValid = false;
         CustomValidator3.ErrorMessage = "*两次密码不一致";
     }
     else
     {
         PsdIselgal   = true;
         args.IsValid = true;
     }
 }
 protected void vldConnectionStringValid_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
 {
     try
     {
         Services.Data.Query.TestConnection(args.Value);
         args.IsValid = true;
     }
     catch (System.Security.SecurityException ex)
     {
         vldConnectionStringValid.ErrorMessage = "Insufficient trust level to create OLEDB connections. You must configure DNN to use a lower trust level or add OLEDBPermission to the current trust level<br />" + "Connection string error: " + ex.Message;
         args.IsValid = false;
     }
     catch (Exception ex)
     {
         vldConnectionStringValid.ErrorMessage = "Connection string error: " + ex.Message;
         args.IsValid = false;
     }
 }
Exemple #28
0
 protected void PercentCustomValidator_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
 {
     if (AmountDropDownList.SelectedIndex == (int)AmountTypes.Percent)
     {
         if (source is System.Web.UI.WebControls.CustomValidator)
         {
             ((System.Web.UI.WebControls.CustomValidator)source).ErrorMessage = "Percent must be between 0.00 and 100.00 percent.";
         }
         decimal val = 0;
         if (decimal.TryParse(AmountTextBox.Text,
                              System.Globalization.NumberStyles.Number,
                              System.Threading.Thread.CurrentThread.CurrentUICulture, out val))
         {
             if (val < 0 | val > 100)
             {
                 args.IsValid = false;
             }
         }
         else
         {
             args.IsValid = false;
         }
     }
     else if (AmountDropDownList.SelectedIndex == (int)AmountTypes.MonetaryAmount)
     {
         if (source is System.Web.UI.WebControls.CustomValidator)
         {
             ((System.Web.UI.WebControls.CustomValidator)source).ErrorMessage = "Value must be a monetary amount.";
         }
         decimal val = 0;
         if (decimal.TryParse(AmountTextBox.Text, System.Globalization.NumberStyles.Currency,
                              System.Threading.Thread.CurrentThread.CurrentUICulture, out val))
         {
             if (val < 0)
             {
                 args.IsValid = false;
             }
         }
         else
         {
             args.IsValid = false;
         }
     }
 }
 protected void CustomValidator1_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
 {
     if (rUserNameText.Text.Equals("用户名"))
     {
         CustomValidator1.ErrorMessage = "*用户名为空";
         args.IsValid = false;
     }
     else if (System.Text.RegularExpressions.Regex.IsMatch(rUserNameText.Text, "^[0-9a-zA-Z]+$") &&
              rUserNameText.Text.Length > 5 && rUserNameText.Text.Length < 11)
     {
         args.IsValid    = true;
         UserNameIselgal = true;
     }
     else
     {
         CustomValidator1.ErrorMessage = "*用户名由6~10位数字和字母构成";
         args.IsValid = false;
     }
 }
Exemple #30
0
 /// <summary>
 /// Custom validator to check user enters number greater than 0
 /// </summary>
 /// <param name="source"></param>
 /// <param name="args"></param>
 protected void CustomValidator_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
 {
     if (args.Value == "")
     {
         args.IsValid = false;
     }
     else
     {
         var isNumber = decimal.TryParse(args.Value, out decimal number);
         if (isNumber && number > 0)
         {
             args.IsValid = true;
         }
         else
         {
             args.IsValid = false;
         }
     }
 }