public void Should_be_valid_when_condition_returns_true_using_instance_property()
        {
            var validator = new CustomValidator<Person, int>((p, v) => p.Age % v == 0);

            var person = new Person {Age = 16};
            Assert.That(validator.Validate(person, 4), Is.True);
        }
        public void Has_default_negated_message()
        {
            var validator = new CustomValidator<Person, int>(v => v % 2 == 0);

            var message = validator.DefaultNegatedErrorMessage;
            Console.WriteLine(message);
            Assert.That(message, Is.Not.Null & Is.Not.Empty);
        }
Example #3
0
    public static void AddErrorMessage(this Page page, string message, string validationGroup = null)
    {
        var validator = new CustomValidator
        {
            IsValid = false,
            ErrorMessage = message,
            ValidationGroup = validationGroup
        };

        page.Validators.Add(validator);
    }
Example #4
0
    private void AddErrorMessage(string message)
    {
        var validator = new CustomValidator
        {
            IsValid = false,
            ErrorMessage = message,
            ValidationGroup = "ChangeEmailVg"
        };

        Service.WriteToLog(message, (int)Membership.GetUser().ProviderUserKey);

        Page.Validators.Add(validator);
    }
Example #5
0
    /// <summary>
    /// Adds a CustomValidator object to the ValidatorCollection
    /// </summary>
    /// <param name="message">Error message to be displayed in the ValidationSummary</param>
    /// <param name="validationGroup">The validationgroup to be used</param>
    public static void AddErrorMessage(this Page page, string message, string validationGroup = null)
    {
        // Create new customvalidator
        var validator = new CustomValidator
        {
            IsValid = false,
            ErrorMessage = message,
            ValidationGroup = validationGroup
        };

        // Add it to the page
        page.Validators.Add(validator);
    }
 private void SetUpCustomValidator(CustomValidator validator) {
     if (Column.DataTypeAttribute != null) {
         switch (Column.DataTypeAttribute.DataType) {
             case DataType.Date:
             case DataType.DateTime:
             case DataType.Time:
                 validator.Enabled = true;
                 DateValidator.ErrorMessage = HttpUtility.HtmlEncode(Column.DataTypeAttribute.FormatErrorMessage(Column.DisplayName));
                 break;
         }
     }
     else if (Column.ColumnType.Equals(typeof(DateTime))) {
         validator.Enabled = true;
         DateValidator.ErrorMessage = HttpUtility.HtmlEncode(DefaultDateAttribute.FormatErrorMessage(Column.DisplayName));
     }
 }
Example #7
0
    protected void DeleteMemberButton_Command(object sender, CommandEventArgs e)
    {
        try
        {
            Membership.DeleteUser(e.CommandArgument.ToString());
            Response.Redirect("~/Administrators/Default.aspx");
        }
        catch
        {
            var validator = new CustomValidator
            {
                IsValid = false,
                ErrorMessage ="An error occured while deleting the member"
            };

            Page.Validators.Add(validator);
        }
    }
Example #8
0
 protected void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         var bandaModelo = new BandaHertzianaModelo();
         bandaModelo.IdBandaHertziana = int.Parse(hdfIdBanda.Value);
         bandaModelo.Descripcion      = txtDescripcion.Text;
         bandaModelo.Del = decimal.Parse(txtDel.Text);
         bandaModelo.Al  = decimal.Parse(txtAl.Text);
         bandaServicio.Editar(bandaModelo);
         Response.Redirect("Index.aspx", true);
     }
     catch (Exception)
     {
         CustomValidator err = new CustomValidator();
         err.IsValid      = false;
         err.ErrorMessage = "Ocurrio un error al editar el registro";
         Page.Validators.Add(err);
     }
 }
Example #9
0
 protected void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         var personaModelo = new PersonaModelo();
         personaModelo.NifPersona = txtNif.Text;
         personaModelo.Nombres    = txtNombre.Text;
         personaModelo.Apellidos  = txtApellidos.Text;
         personaModelo.Direccion  = txtDireccion.Text;
         personaServicio.Editar(personaModelo);
         Response.Redirect("Index.aspx", true);
     }
     catch (Exception)
     {
         CustomValidator err = new CustomValidator();
         err.IsValid      = false;
         err.ErrorMessage = "Ocurrio un error al editar el registro";
         Page.Validators.Add(err);
     }
 }
Example #10
0
        private void SetearValidadores()
        {
            if (this.radioTipo.Checked)
            {
                this.phValidTipoGuia.Controls.Add(GenerarValidadores.Requerido("ddlTipoGuia", this.TraducirTexto("Errores.Obligatorios.TipoGuia"), false, "validTipoGuia"));
                this.phValidNroSucursal.Controls.Add(GenerarValidadores.Requerido("txtNroSucursal", this.TraducirTexto("Errores.Obligatorios.NroSucursal"), false, "validNroSucursal"));
                this.phValidNroGuia.Controls.Add(GenerarValidadores.Requerido("txtNroGuia", this.TraducirTexto("Errores.Obligatorios.NroGuia"), false, "validNroGuia"));

                this.phValidNroSucursal.Controls.Add(GenerarValidadores.Entero("txtNroSucursal", this.TraducirTexto("Errores.Invalidos.NroSucursal"), false, "validNroSucursalInv"));
                this.phValidNroGuia.Controls.Add(GenerarValidadores.Entero("txtNroGuia", this.TraducirTexto("Errores.Invalidos.NroGuia"), false, "validNroGuiaInv"));
                //phNuevo.Controls.Add(GenerarValidadores.Requerido("txtSiniestro", "Debe ingresar un número de siniestro o acta de infracción, es obligatorio", false, "siniestroReq"));
                CustomValidator validadorRBT = (CustomValidator)GenerarValidadores.Custom();
                validadorRBT.ServerValidate += new System.Web.UI.WebControls.ServerValidateEventHandler(ValidateSiniestro);
                phNuevo.Controls.Add(validadorRBT);
            }
            else
            {
                this.phValidCodigoBarra.Controls.Add(GenerarValidadores.Requerido("txtCodigoBarra", this.TraducirTexto("Errores.Obligatorios.CodigoBarraGuia"), false, "validCodigoBarra"));
            }
        }
Example #11
0
    public Store DbToDomain(StoreDbModel item)
    {
        CustomValidator.ValidateObject(item);
        var storeDbModel = _context.Stores.Where(e => e.Id.Equals(item.Id))
                           .Include(e => e.StoreCategoryRelation)
                           .ThenInclude(e => e.CategoryDbModel)
                           .Include(e => e.StoreProductRelation)
                           .ThenInclude(e => e.ProductDbModel).FirstOrDefault();

        return(new Store
               (
                   (from categoryDbModel in storeDbModel.CategoryDbModels
                    select _categoryMapper.DbToDomainStoreSpecificProducts(categoryDbModel, item.Id)).ToList(),
                   item.Id,
                   item.Name,
                   item.Location,
                   item.MallId,
                   item.Profit
               ));
    }
Example #12
0
 public IActionResult Create([FromBody] OrderAddVM model)
 {
     if (!ModelState.IsValid)
     {
         var errors = CustomValidator.GetErrorsByModel(ModelState);
         return(BadRequest(errors));
     }
     {
         Order m = new Order
         {
             CarId    = model.Car.Id,
             Price    = float.Parse(model.Car.Price.ToString()),
             ClientId = model.Client.Id,
             Date     = model.Date
         };
         _context.Orders.Add(m);
         _context.SaveChanges();
         return(Ok("Дані добалено"));
     }
 }
Example #13
0
 protected void btnGuardar_Click1(object sender, EventArgs e)
 {
     try
     {
         var mcModelo = new MediosComunicacionModelo();
         mcModelo.Nombre     = txtNombre.Text;
         mcModelo.Direccion  = txtDireccion.Text;
         mcModelo.Nif        = txtNif.Text;
         mcModelo.NifPersona = txtNifRep.Text;
         mcComunicacion.Editar(mcModelo);
         Response.Redirect("Index.aspx", true);
     }
     catch (Exception)
     {
         CustomValidator err = new CustomValidator();
         err.IsValid      = false;
         err.ErrorMessage = "Ocurrio un error al editar el registro";
         Page.Validators.Add(err);
     }
 }
Example #14
0
        protected void UpploadButton_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                try
                {
                    Session["FileName"]      = Gallery.SaveImage(FileUpload.FileContent, FileUpload.FileName);
                    Session["UploadSuccess"] = true;
                    Response.Redirect("http://localhost:50168/Default.aspx?name=" + Session["FileName"]);
                }

                catch
                {
                    CustomValidator customvalidator = new CustomValidator();
                    customvalidator.IsValid      = false;
                    customvalidator.ErrorMessage = "Validation Error!";
                    Page.Validators.Add(customvalidator);
                }
            }
        }
Example #15
0
 private void SetUpCustomValidator(CustomValidator validator)
 {
     if (Column.DataTypeAttribute != null)
     {
         switch (Column.DataTypeAttribute.DataType)
         {
         case DataType.Date:
         case DataType.DateTime:
         case DataType.Time:
             validator.Enabled          = true;
             DateValidator.ErrorMessage = HttpUtility.HtmlEncode(Column.DataTypeAttribute.FormatErrorMessage(Column.DisplayName));
             break;
         }
     }
     else if (Column.ColumnType == typeof(DateTime))
     {
         validator.Enabled          = true;
         DateValidator.ErrorMessage = HttpUtility.HtmlEncode(DefaultDateAttribute.FormatErrorMessage(Column.DisplayName));
     }
 }
Example #16
0
        public ResponseObject <FormModel> Post(FormModel model)
        {
            var response = new ResponseObject <FormModel>
            {
                Data = model
            };

            if (CustomValidator.Validate(model))
            {
                response.Ok         = true;
                response.Message    = "Model is valid";
                Response.StatusCode = 201;
            }
            else
            {
                response.Ok      = false;
                response.Message = "Model is invalid";
            }
            return(response);
        }
Example #17
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                var contratoModelo = new ContratoModelo();
                contratoModelo.NoContrato      = txtContrado.Text;
                contratoModelo.Duracion        = int.Parse(txtDuracion.Text);
                contratoModelo.NifPatrocinador = txtNifPatrocinador.Text;

                contratoServicio.Editar(contratoModelo);
                Response.Redirect("Index.aspx", true);
            }
            catch (Exception)
            {
                CustomValidator err = new CustomValidator();
                err.IsValid      = false;
                err.ErrorMessage = "Ocurrio un error al editar el registro";
                Page.Validators.Add(err);
            }
        }
        public User(string username, string firstName, string lastName, string password, string role)
        {
            CustomValidator.ValidateSymbols(username, Constants.UsernamePattern, Constants.InvalidSymbols);
            CustomValidator.ValidateStringRange(username, Constants.MinNameLength, Constants.MaxNameLength, Constants.StringMustBeBetweenMinAndMax);

            CustomValidator.ValidateSymbols(password, Constants.PasswordPattern, Constants.InvalidSymbols);
            CustomValidator.ValidateStringRange(password, Constants.MinPasswordLength, Constants.MaxPasswordLength, Constants.StringMustBeBetweenMinAndMax);
            //All readonly validation up ! <--

            //NO Validation for FirstName and LastName constants available but REQUIRED ?!
            CustomValidator.ValidateStringRange(firstName, Constants.MinNameLength, Constants.MaxNameLength, Constants.StringMustBeBetweenMinAndMax);
            CustomValidator.ValidateStringRange(lastName, Constants.MinNameLength, Constants.MaxNameLength, Constants.StringMustBeBetweenMinAndMax);
            //TODO: NO DIRECT Validation for Role

            this.Username  = username;
            this.FirstName = firstName;
            this.LastName  = lastName;
            this.Password  = password;
            this.Role      = (Role)Enum.Parse(typeof(Role), role);
        }
Example #19
0
 protected void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         var franjaModelo = new FranjaHorarioModelo();
         franjaModelo.IdFranjaHorario = int.Parse(hdfIdFranja.Value);
         franjaModelo.HoraInicio      = txtHoraInicio.Text;
         franjaModelo.HoraFin         = txtHoraFin.Text;
         franjaModelo.DiaSemana       = ddlDiaSemana.SelectedValue;
         franjaServicio.Editar(franjaModelo);
         Response.Redirect("Index.aspx", true);
     }
     catch (Exception)
     {
         CustomValidator err = new CustomValidator();
         err.IsValid      = false;
         err.ErrorMessage = "Ocurrio un error al editar el registro";
         Page.Validators.Add(err);
     }
 }
        public async Task AddProductToStore(Product product, Guid storeId)
        {
            CustomValidator.ValidateObject(product);
            CustomValidator.ValidateId(storeId);
            await using var context = new MyDbContext(_options);
            if (!Exists(product.Id))
            {
                await AddOne(product);
            }

            var storeProdRelExists = await StoreProductRelationExists(storeId, product.Id);

            if (!storeProdRelExists)
            {
                var storeProdRel = new StoreProductDbModel(storeId, product.Id);
                await context.StoreProductRelation.AddAsync(storeProdRel);
            }

            await context.SaveChangesAsync();
        }
        public void Deny_Unrestricted()
        {
            ValidatorCollection vc = new ValidatorCollection();

            Assert.AreEqual(0, vc.Count, "Count");
            Assert.IsFalse(vc.IsReadOnly, "IsReadOnly");
            Assert.IsFalse(vc.IsSynchronized, "IsSynchronized");
            Assert.IsNotNull(vc.SyncRoot, "SyncRoot");

            vc.Add(null);
            Assert.IsNull(vc[0], "this[int]");
            Assert.IsTrue(vc.Contains(null), "Contains");
            Assert.IsNotNull(vc.GetEnumerator(), "GetEnumerator");
            vc.Remove(null);

            IValidator validator = new CustomValidator();

            vc.Add(validator);
            vc.CopyTo(new IValidator[1], 0);
        }
Example #22
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                var programaModelo = new ProgramasModelo();
                programaModelo.NifPersona = txtNifRep.Text;
                programaModelo.Nombre     = txtNombrePrograma.Text;
                programaModelo.IdPrograma = int.Parse(hdfIdPrograma.Value);

                programaServicio.Editar(programaModelo);
                Response.Redirect("Index.aspx", true);
            }
            catch (Exception)
            {
                CustomValidator err = new CustomValidator();
                err.IsValid      = false;
                err.ErrorMessage = "Ocurrio un error al editar el registro";
                Page.Validators.Add(err);
            }
        }
Example #23
0
        /// <summary>
        /// Validate the verify new password textbox
        /// </summary>
        /// <param name="source">Validator object</param>
        /// <param name="args">Validator arguments</param>
        public void ValidateVerifyPassword(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            CustomValidator val = (CustomValidator)source;

            if (args.Value.Length == 0)
            {
                args.IsValid     = false;
                val.ErrorMessage = Master.GetLocalizedString("PxWebAdminSettingsValidationMandatorySetting");
                return;
            }

            if (!txtNewPassword.Text.Equals(txtVerifyPassword.Text))
            {
                args.IsValid     = false;
                val.ErrorMessage = Master.GetLocalizedString("PxWebAdminToolsChangePasswordVerifyIncorrect");
                return;
            }

            args.IsValid = true;
        }
Example #24
0
        //验证缺少子科目
        void lackSonValidator_ServerValidate(object source, ServerValidateEventArgs args)
        {
            if (Convert.ToInt32(args.Value) > 2)
            {
                args.IsValid = true;
                return;
            }
            CustomValidator lackSonValidator = (CustomValidator)source;
            int             subjectId        = Convert.ToInt32(lackSonValidator.ID.Replace("lackSonValidator", ""));

            foreach (Model.CCOM.Subject model in subjectDic.Values)
            {
                if (model.Fs_id == subjectId)
                {
                    args.IsValid = true;
                    return;
                }
            }
            args.IsValid = false;
        }
Example #25
0
        public async Task <IActionResult> Create(FormUserViewModel model)
        {
            if (!CustomValidator.Validate(model))
            {
                return(this.View(model));
            }

            if (!(await this.UserService.IsUsernameFree(model.Username)))
            {
                model.ErrorMessages = new List <string>(model.ErrorMessages)
                {
                    "Username is taken!"
                }.ToArray();
                return(this.View(model));
            }

            await this.UserService.CreateUser(model.Username, model.Password);

            return(this.RedirectToAction("All"));
        }
Example #26
0
 private void SetearValidadores()
 {
     try
     {
         phFechaDesde.Controls.Add(GenerarValidadores.Fecha("txtFechaDesde", "La fecha desde debe tener el formato DD/MM/AAAA", true, "desdeValid"));
         phFechaDesde.Controls.Add(GenerarValidadores.Requerido("txtFechaDesde", "Debe ingresar la fecha Desde", true, "desdeReq"));
         phFechaHasta.Controls.Add(GenerarValidadores.Fecha("txtFechaHasta", "La fecha hasta debe tener el formato DD/MM/AAAA", true, "hastaValid"));
         phFechaHasta.Controls.Add(GenerarValidadores.Requerido("txtFechaHasta", "Debe ingresar la fecha Hasta", true, "hastaReq"));
         PHDesdeImporteTotal.Controls.Add(GenerarValidadores.Entero("TxtDesdeImporte", "El valor ingresado en Desde Importe Total es incorrecto. Debe ingresar un número sin decimales", true, "ValidarCampoDesdeImporte"));
         PHHastaImporteTotal.Controls.Add(GenerarValidadores.Rango("TxtDesdeImporte", "TxtHastaImporte", "El campo Hasta Importe Total debe ser mayor al campo Desde Importe Total", true, "ValidarDesdeHastaImporte", true));
         PHHastaImporteTotal.Controls.Add(GenerarValidadores.Entero("TxtHastaImporte", "El valor ingresado en Hasta Importe Total es incorrecto. Debe ingresar un número sin decimales", true, "ValidarCampoHastaImporte"));
         CustomValidator validRango = (CustomValidator)GenerarValidadores.Custom("", "", true, "rangoValid");
         validRango.ServerValidate += new System.Web.UI.WebControls.ServerValidateEventHandler(ValidateRango);
         phFechaHasta.Controls.Add(validRango);
     }
     catch (Exception ex)
     {
         ((ErrorWeb)phErrores.Controls[0]).setMensaje(ex.Message);
     }
 }
Example #27
0
        public async Task <ResultDTO> Login([FromBody] UserLoginDTO model)
        {
            if (!ModelState.IsValid)
            {
                return(new ErrorResultDTO
                {
                    StatusCode = 401,
                    Message = "Login Error",
                    Errors = CustomValidator.GetErrorByModel(ModelState)
                });
            }

            // Перевірка на успіх логіну та паролю
            var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, false, false);

            if (!result.Succeeded)
            {
                return(new ErrorResultDTO {
                    StatusCode = 402,
                    Message = "Login failed",
                    Errors = new System.Collections.Generic.List <string>
                    {
                        "Login or password error"
                    }
                });
            }
            else
            {
                var user = await _userManager.FindByEmailAsync(model.Email);

                // вхід
                await _signInManager.SignInAsync(user, false);

                return(new SuccessResultDTO
                {
                    StatusCode = 200,
                    Message = "Ok",
                    Token = _jwtTokenService.CreateToken(user)
                });
            }
        }
Example #28
0
        private void AddRequiredChkBoxValidator(webforms_sheetfielddef sfd, float CheckBoxXOffset, float CheckBoxYOffset)
        {
            if (sfd.IsRequired != (sbyte)1)
            {
                return;
            }
            int    XPosErrorMessageOffset = 2;
            int    XPos         = sfd.XPos;
            int    YPos         = sfd.YPos;
            String ErrorMessage = "This is a required section. Please check one of the Check Boxes";
            //add dummy textbox to get around the limitation of checkboxes not having validators and call outs.
            TextBox tb = new TextBox();

            tb.Rows              = 1;
            tb.Text              = ".";// there has to be some character here the least visible is the period.
            tb.MaxLength         = 1;
            tb.Width             = Unit.Pixel(1);
            tb.ID                = "TextBoxForCheckbox" + sfd.WebSheetFieldDefID;
            tb.Style["position"] = "absolute";
            tb.Style["top"]      = YPos + CheckBoxYOffset + "px";
            tb.Style["left"]     = XPos + CheckBoxXOffset + XPosErrorMessageOffset + sfd.Width + "px";
            tb.Style["z-index"]  = "-2";
            tb.ReadOnly          = true;
            tb.BorderWidth       = Unit.Pixel(0);
            Panel1.Controls.Add(tb);
            CustomValidator cv = new CustomValidator();

            cv.ControlToValidate = tb.ID;
            cv.ErrorMessage      = ErrorMessage;
            cv.Display           = ValidatorDisplay.None;
            cv.SetFocusOnError   = true;
            cv.ID = "CustomValidator" + cv.ControlToValidate;
            cv.ClientValidationFunction = "CheckCheckBoxes";
            Panel1.Controls.Add(cv);
            //callout extender
            AjaxControlToolkit.ValidatorCalloutExtender vc = new AjaxControlToolkit.ValidatorCalloutExtender();
            vc.TargetControlID = cv.ID;
            vc.ID = "ValidatorCalloutExtender" + cv.ID;
            Panel1.Controls.Add(vc);
            AddChkBoxIdsToHashTable(sfd);
        }
Example #29
0
        public async Task <ResultDTO> Login([FromBody] UserLoginDTO model)
        {
            if (!ModelState.IsValid)
            {
                return(new ResultErrorDTO
                {
                    Status = 403,
                    Message = "Invalid data for login",
                    Errors = CustomValidator.GetErrorsByModel(ModelState)
                });
            }

            //Переірка на успіх з логіном та паролем
            var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, false, false);

            if (!result.Succeeded)
            {
                return(new ResultErrorDTO
                {
                    Status = 401,
                    Message = "Error",
                    Errors = new List <string>()
                    {
                        "Incorrect login or password!"
                    }
                });
            }
            else
            {
                var user = await _userManager.FindByEmailAsync(model.Email);

                await _signInManager.SignInAsync(user, false);

                return(new ResultLoginDTO
                {
                    Status = 200,
                    Message = "OK",
                    Token = _jWTTokenService.CreateToken(user)
                });
            }
        }
        public void LoadDetails()
        {
            _validationGroup = SessionHandler.MappingOPSRegionValidationGroup;
            this.ButtonSave.ValidationGroup = _validationGroup;
            foreach (Control cntrl in this.PanelPopupMappingDetails.Controls)
            {
                if (cntrl is TextBox)
                {
                    TextBox txtBox = (TextBox)cntrl;
                    txtBox.ValidationGroup = _validationGroup;
                }
                if (cntrl is RequiredFieldValidator)
                {
                    RequiredFieldValidator reqFieldValidator = (RequiredFieldValidator)cntrl;
                    reqFieldValidator.ValidationGroup = _validationGroup;
                }
                if (cntrl is CustomValidator)
                {
                    CustomValidator custValidator = (CustomValidator)cntrl;
                    custValidator.ValidationGroup = _validationGroup;
                }
                if (cntrl is System.Web.UI.WebControls.DropDownList)
                {
                    System.Web.UI.WebControls.DropDownList ddList = (System.Web.UI.WebControls.DropDownList)cntrl;
                    ddList.ValidationGroup = _validationGroup;
                }
            }

            switch (SessionHandler.MappingOPSRegionDefaultMode)
            {
            case (int)App.BLL.Mappings.Mode.Insert:
                this.LoadInsertMode();

                break;

            case (int)App.BLL.Mappings.Mode.Edit:
                this.LoadEditMode();

                break;
            }
        }
Example #31
0
        public async Task <ResultDto> Login([FromBody] UserLoginDto model)
        {
            if (!ModelState.IsValid)
            {
                return(new ResultErrorDto
                {
                    Status = 400,
                    Message = "ERROR",
                    Errors = CustomValidator.GetErrorsByModel(ModelState)
                });
            }
            else
            {
                var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, false, false);

                if (!result.Succeeded)
                {
                    List <string> error = new List <string>();
                    error.Add("User is not found, password or email isn't correct!");
                    return(new ResultErrorDto
                    {
                        Status = 400,
                        Message = "user not found!",
                        Errors = error
                    });
                }
                else
                {
                    var user = await _userManager.FindByEmailAsync(model.Email);

                    await _signInManager.SignInAsync(user, false);

                    return(new ResultLoginDto
                    {
                        Status = 200,
                        Message = "OK",
                        Token = _jwtTokenService.CreateToken(user)
                    });
                }
            }
        }
        public async Task <ResultDTO> Register([FromBody] UserRegisterDTO model)
        {
            if (!ModelState.IsValid)
            {
                return(new ResultErrorDTO
                {
                    Status = 500,
                    Errors = CustomValidator.GetErrorsByModel(ModelState)
                });
            }

            var user = new User()
            {
                UserName = model.Email,
                Email    = model.Email,
                Balance  = 0
            };

            var result = await _userManager.CreateAsync(user, model.Password);

            if (!result.Succeeded)
            {
                _logger.LogInformation($"User: email: {user.Email} register failed");
                return(new ResultErrorDTO
                {
                    Status = 500,
                    Errors = CustomValidator.GetErrorsByIdentityResult(result)
                });
            }
            else
            {
                _logger.LogInformation($"User registered: id: {user.Id} email: {user.Email}");
                result = _userManager.AddToRoleAsync(user, "User").Result;
                await _context.SaveChangesAsync();
            }

            return(new ResultDTO
            {
                Status = 200
            });
        }
        private void butGuardar_Click(object sender, System.EventArgs e)
        {
            try
            {
                CustomValidator valAgencia = (CustomValidator)this.phValidAgencia.FindControl("valAgencia");
                valAgencia.Enabled = true;
                valAgencia.Validate();
                if (!valAgencia.IsValid)
                {
                    return;
                }

                IStockFormulario stock = StockFormularioFactory.GetStockFormularioFactory();
                stock.NroInternoDesde         = Convert.ToInt32(this.txtNroInternoDesde.Text.Trim());
                stock.NroInternoHasta         = Convert.ToInt32(this.txtNroInternoHasta.Text.Trim());
                stock.AgenciaID               = this.busqAgencia.AgenciaID.Trim().Equals("")?0:Convert.ToInt32(this.busqAgencia.AgenciaID.Trim());
                stock.SucursalDGI             = this.busqAgencia.Sucursal.Trim();
                stock.UsuarioID               = this.usuario.UsuarioID;
                stock.Observaciones           = this.txtObservaciones.Text.Trim();
                stock.EstadoStockFormularioID = Convert.ToInt32(this.ddlEstadoStockFormulario.SelectedValue.Trim());
                stock.Guardar();
                this.BindGrid(0);
            }
            catch (Exception ex)
            {
                string mensaje = ex.Message;
                try
                {
                    mensaje = this.TraducirTexto(ex.Message);
                    if (mensaje == "" || mensaje == null)
                    {
                        mensaje = ex.Message;
                    }
                }
                catch (Exception)
                {
                    mensaje = ex.Message;
                }
                ((ErrorWeb)this.phErrores.Controls[0]).setMensaje(mensaje);
            }
        }
Example #34
0
        protected void RenameOKButton_Click(object sender, EventArgs e)
        {
            string targetFileName = FileHelper.GetSafeBaseImageName(RenameName.Text, true);

            if (!string.IsNullOrEmpty(targetFileName) && FileHelper.IsExtensionValid(targetFileName, AbleContext.Current.Store.Settings.FileExt_Themes))
            {
                string fullTargetFileName = Path.Combine(this.FullCurrentPath, targetFileName);
                if (fullTargetFileName != this.FullCurrentFileName)
                {
                    if (!File.Exists(fullTargetFileName))
                    {
                        File.Move(this.FullCurrentFileName, fullTargetFileName);
                        this.CurrentFileName = targetFileName;
                        BindCurrentFile();
                        BindFileListRepeater(true);
                    }
                    else
                    {
                        FileErrorMessage.Text    = "Target file already exists.";
                        FileErrorMessage.Visible = true;
                    }
                }
                else
                {
                    FileErrorMessage.Text    = "Souce and target file names are same.";
                    FileErrorMessage.Visible = true;
                }
            }
            else
            {
                CustomValidator filetype = new CustomValidator();
                filetype.IsValid           = false;
                filetype.ControlToValidate = "RenameName";
                filetype.ErrorMessage      = "'" + targetFileName + "' is not a valid file name.";
                filetype.Text            = "*";
                filetype.ValidationGroup = "Rename";
                phRenameValidFiles.Controls.Add(filetype);
                RenamePopup.Show();
            }
            RenameName.Text = string.Empty;
        }
Example #35
0
        protected void gvImport_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            try
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    //Import selImport = e.Row.DataItem as Import;
                    //int importId = int.Parse(DataBinder.Eval(e.Row.DataItem, "Id").ToString());

                    //Button cmd = e.Row.FindControl("cmdDelete") as Button;
                    //cmd.CommandArgument = importId.ToString();
                }
            }
            catch (Exception ex)
            {
                var myCustomValidator = new CustomValidator();
                myCustomValidator.IsValid      = false;
                myCustomValidator.ErrorMessage = ex.Message;
                Page.Validators.Add(myCustomValidator);
            }
        }
    public void AddOne(Store item)
    {
        CustomValidator.ValidateObject(item);
        var exists = Exists(item.Id);

        if (!exists)
        {
            var storeWithTheSameLocationAndNameExists = _context.Stores.Any(st =>
                                                                            st.Location.Equals(item.Location) &&
                                                                            st.Name.Equals(item.Name) &&
                                                                            !st.Id.Equals(item.Id) &&
                                                                            st.MallId == null);
            if (storeWithTheSameLocationAndNameExists)
            {
                return;
            }
            var enState = _context.Stores.Add(_storeMapper.DomainToDb(item));
            enState.State = EntityState.Added;
            _context.SaveChanges();
        }
    }
Example #37
0
    protected void ValidEndDateCheck(object sender, ServerValidateEventArgs e)
    {
        try
        {
            CustomValidator cv         = (CustomValidator)sender;
            GridViewRow     grdRow     = ((GridViewRow)cv.Parent.Parent);
            TextBox         txtEndDate = grdRow.RowType == DataControlRowType.Footer ? (TextBox)grdRow.FindControl("txtNewEndDate") : (TextBox)grdRow.FindControl("txtEndDate");

            if (!IsValidDate(txtEndDate.Text))
            {
                throw new Exception();
            }

            DateTime d = GetDate(txtEndDate.Text);
            e.IsValid = (d == DateTime.MinValue) || Utilities.IsValidDBDateTime(d);
        }
        catch (Exception)
        {
            e.IsValid = false;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        SuperForm1 = new SuperForm();
        SuperForm1.ID = "SuperForm1";
        SuperForm1.DataSourceID = "SqlDataSource1";
        SuperForm1.AutoGenerateRows = false;
        SuperForm1.AutoGenerateInsertButton = true;
        SuperForm1.AutoGenerateEditButton = true;
        SuperForm1.AutoGenerateDeleteButton = true;
        SuperForm1.DataKeyNames = new string[] { "EmployeeID" };
        SuperForm1.AllowPaging = true;
             
        SuperForm1.ValidationGroup = "Group1";
        SuperForm1.DefaultMode = DetailsViewMode.Insert;
        SuperForm1.ItemCommand += SuperForm1_ItemCommand;

        Obout.SuperForm.BoundField field1 = new Obout.SuperForm.BoundField();
        field1.DataField = "EmployeeID";
        field1.HeaderText = "Employee ID";
        field1.ReadOnly = true;
        field1.InsertVisible = false;

        RequiredFieldValidator field2Required = new RequiredFieldValidator();
        field2Required.ID = "FirstNameValidator";
        field2Required.Display = ValidatorDisplay.None;
        field2Required.ErrorMessage = "First Name is mandatory";

        ValidatorCalloutExtender field2CalloutExtender = new ValidatorCalloutExtender();
        field2CalloutExtender.ID = "FirstNameValidatorCallout";
        field2CalloutExtender.TargetControlID = "FirstNameValidator";
        field2CalloutExtender.Width = 250;
        field2CalloutExtender.HighlightCssClass = "highlight";
        field2CalloutExtender.WarningIconImageUrl = "resources/icons/warning.gif";
        field2CalloutExtender.CloseImageUrl = "resources/icons/close.gif";

        Obout.SuperForm.BoundField field2 = new Obout.SuperForm.BoundField();
        field2.DataField = "FirstName";
        field2.HeaderText = "First Name";
        field2.Validators.Add(field2Required);
        field2.Validators.Add(field2CalloutExtender);

        RequiredFieldValidator field3Required = new RequiredFieldValidator();
        field3Required.ID = "LastNameValidator";
        field3Required.Display = ValidatorDisplay.None;
        field3Required.ErrorMessage = "Last Name is mandatory";
        field3Required.Text = "*";

        ValidatorCalloutExtender field3CalloutExtender = new ValidatorCalloutExtender();
        field3CalloutExtender.ID = "LastNameValidatorCallout";
        field3CalloutExtender.TargetControlID = "LastNameValidator";
        field3CalloutExtender.Width = 250;
        field3CalloutExtender.HighlightCssClass = "highlight";
        field3CalloutExtender.WarningIconImageUrl = "resources/icons/warning.gif";
        field3CalloutExtender.CloseImageUrl = "resources/icons/close.gif";

        Obout.SuperForm.BoundField field3 = new Obout.SuperForm.BoundField();
        field3.DataField = "LastName";
        field3.HeaderText = "Last Name";
        field3.Validators.Add(field3Required);
        field3.Validators.Add(field3CalloutExtender);

        RequiredFieldValidator field4Required = new RequiredFieldValidator();
        field4Required.ID = "TitleOfCourtesyValidator1";
        field4Required.Display = ValidatorDisplay.None;
        field4Required.ErrorMessage = "Courtesy Title is mandatory";
        field4Required.Text = "*";

        ValidatorCalloutExtender field4Callout1 = new ValidatorCalloutExtender();
        field4Callout1.ID = "TitleOfCourtesyValidatorCallout1";
        field4Callout1.TargetControlID = "TitleOfCourtesyValidator1";
        field4Callout1.Width = 250;
        field4Callout1.HighlightCssClass = "highlight";
        field4Callout1.WarningIconImageUrl = "resources/icons/warning.gif";
        field4Callout1.CloseImageUrl = "resources/icons/close.gif";

        CustomValidator field4Custom = new CustomValidator();
        field4Custom.ID = "TitleOfCourtesyValidator2";
        field4Custom.ServerValidate += ValidateTitle;
        field4Custom.Display = ValidatorDisplay.Dynamic;
        field4Custom.ErrorMessage = "Courtesy Title needs to be 'Mr.', 'Ms.', 'Mrs.' or 'Dr.'";
        field4Custom.Text = "Courtesy Title needs to be 'Mr.', 'Ms.', 'Mrs.' or 'Dr.'";

        Obout.SuperForm.BoundField field4 = new Obout.SuperForm.BoundField();
        field4.DataField = "TitleOfCourtesy";
        field4.HeaderText = "Courtesy Title";
        field4.Validators.Add(field4Required);
        field4.Validators.Add(field4Callout1);
        field4.Validators.Add(field4Custom);

        RequiredFieldValidator field5Required = new RequiredFieldValidator();
        field5Required.ID = "BirthDateValidator1";
        field5Required.Display = ValidatorDisplay.None;
        field5Required.ErrorMessage = "Birth Date is mandatory";
        field5Required.Text = "*";

        ValidatorCalloutExtender field5Callout1 = new ValidatorCalloutExtender();
        field5Callout1.ID = "BirthDateValidatorCallout1";
        field5Callout1.TargetControlID = "BirthDateValidator1";
        field5Callout1.Width = 250;
        field5Callout1.HighlightCssClass = "highlight";
        field5Callout1.WarningIconImageUrl = "resources/icons/warning.gif";
        field5Callout1.CloseImageUrl = "resources/icons/close.gif";

        RangeValidator field5Range = new RangeValidator();
        field5Range.ID = "BirthDateValidator2";
        field5Range.Display = ValidatorDisplay.None;
        field5Range.MinimumValue = "1900/1/1";
        field5Range.MaximumValue = "2039/12/31";
        field5Range.Type = ValidationDataType.Date;
        field5Range.ErrorMessage = "Birth Date needs to be in this format: mm/dd/yyyy";
        field5Range.Text = "*";

        ValidatorCalloutExtender field5Callout2 = new ValidatorCalloutExtender();
        field5Callout2.ID = "BirthDateValidatorCallout2";
        field5Callout2.TargetControlID = "BirthDateValidator2";
        field5Callout2.Width = 250;
        field5Callout2.HighlightCssClass = "highlight";
        field5Callout2.WarningIconImageUrl = "resources/icons/warning.gif";
        field5Callout2.CloseImageUrl = "resources/icons/close.gif";

        Obout.SuperForm.DateField field5 = new Obout.SuperForm.DateField();
        field5.DataField = "BirthDate";
        field5.HeaderText = "Birth Date";
        field5.DataFormatString = "{0:MM/dd/yyyy}";
        field5.ApplyFormatInEditMode = true;
        field5.Validators.Add(field5Required);
        field5.Validators.Add(field5Callout1);
        field5.Validators.Add(field5Range);
        field5.Validators.Add(field5Callout2);

        RequiredFieldValidator field6Required = new RequiredFieldValidator();
        field6Required.ID = "HomePhoneValidator1";
        field6Required.Display = ValidatorDisplay.None;
        field6Required.ErrorMessage = "Home Phone is mandatory";
        field6Required.Text = "*";

        ValidatorCalloutExtender field6Callout1 = new ValidatorCalloutExtender();
        field6Callout1.ID = "HomePhoneValidatorCallout1";
        field6Callout1.TargetControlID = "HomePhoneValidator1";
        field6Callout1.Width = 250;
        field6Callout1.HighlightCssClass = "highlight";
        field6Callout1.WarningIconImageUrl = "resources/icons/warning.gif";
        field6Callout1.CloseImageUrl = "resources/icons/close.gif";

        RegularExpressionValidator field6Range = new RegularExpressionValidator();
        field6Range.ID = "HomePhoneValidator2";
        field6Range.Display = ValidatorDisplay.None;
        field6Range.ValidationExpression = "^(\\(?\\s*\\d{3}\\s*[\\)\\-\\.]?\\s*)?[1-9]\\d{2}\\s*[\\-\\.]\\s*\\d{4}$";
        field6Range.ErrorMessage = "Home Phone must be in this format (###) ###-####";
        field6Range.Text = "*";

        ValidatorCalloutExtender field6Callout2 = new ValidatorCalloutExtender();
        field6Callout2.ID = "HomePhoneValidatorCallout2";
        field6Callout2.TargetControlID = "HomePhoneValidator2";
        field6Callout2.Width = 250;
        field6Callout2.HighlightCssClass = "highlight";
        field6Callout2.WarningIconImageUrl = "resources/icons/warning.gif";
        field6Callout2.CloseImageUrl = "resources/icons/close.gif";

        Obout.SuperForm.BoundField field6 = new Obout.SuperForm.BoundField();
        field6.DataField = "HomePhone";
        field6.HeaderText = "Home Phone";
        field6.Validators.Add(field6Required);
        field6.Validators.Add(field6Callout1);
        field6.Validators.Add(field6Range);
        field6.Validators.Add(field6Callout2);

        SuperForm1.Fields.Add(field1);
        SuperForm1.Fields.Add(field2);
        SuperForm1.Fields.Add(field3);
        SuperForm1.Fields.Add(field4);
        SuperForm1.Fields.Add(field5);
        SuperForm1.Fields.Add(field6);

        SuperForm1Container.Controls.Add(SuperForm1);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        SuperForm1 = new SuperForm();
        SuperForm1.ID = "SuperForm1";
        SuperForm1.Title = "Employee Form";
        SuperForm1.DataSourceID = "SqlDataSource1";
        SuperForm1.AutoGenerateRows = false;
        SuperForm1.AutoGenerateInsertButton = true;
        SuperForm1.AutoGenerateEditButton = true;
        SuperForm1.AutoGenerateDeleteButton = true;
        SuperForm1.DataKeyNames = new string[] { "EmployeeID" };
        SuperForm1.AllowPaging = true;
        SuperForm1.DefaultMode = DetailsViewMode.Edit;

        CustomValidator field4Custom = new CustomValidator();
        field4Custom.ID = "CustomValidator1";
        field4Custom.ServerValidate += ValidateTitle;
        field4Custom.ErrorMessage = "Title needs to be 'Mr.', 'Ms.', 'Mrs.' or 'Dr.'";
        field4Custom.Display = ValidatorDisplay.Dynamic;

        RangeValidator field5Custom = new RangeValidator();
        field5Custom.ID = "RangeValidator1";
        field5Custom.MinimumValue = "1900/1/1";
        field5Custom.MaximumValue = "2039/12/31";
        field5Custom.Type = ValidationDataType.Date;
        field5Custom.ErrorMessage = "*";

        RegularExpressionValidator field6Custom = new RegularExpressionValidator();
        field6Custom.ID = "RegularExpressionValidator1";
        field6Custom.Display = ValidatorDisplay.Dynamic;
        field6Custom.ValidationExpression = "^(\\(?\\s*\\d{3}\\s*[\\)\\-\\.]?\\s*)?[1-9]\\d{2}\\s*[\\-\\.]\\s*\\d{4}$";
        field6Custom.ErrorMessage = "Phone numbers must have this format (###) ###-####";

        Obout.SuperForm.BoundField field1 = new Obout.SuperForm.BoundField();
        field1.DataField = "EmployeeID";
        field1.HeaderText = "Employee ID";
        field1.ReadOnly = true;
        field1.InsertVisible = false;

        Obout.SuperForm.BoundField field2 = new Obout.SuperForm.BoundField();
        field2.DataField = "FirstName";
        field2.HeaderText = "First Name";
        field2.Required = true;

        Obout.SuperForm.BoundField field3 = new Obout.SuperForm.BoundField();
        field3.DataField = "LastName";
        field3.HeaderText = "Last Name";
        field3.Required = true;

        Obout.SuperForm.BoundField field4 = new Obout.SuperForm.BoundField();
        field4.DataField = "TitleOfCourtesy";
        field4.HeaderText = "Courtesy Title";
        field4.Required = true;
        field4.Validators.Add(field4Custom);
                
        Obout.SuperForm.DateField field5 = new Obout.SuperForm.DateField();
        field5.DataField = "BirthDate";
        field5.HeaderText = "Birth Date";
        field5.Required = true;
        field5.DataFormatString = "{0:MM/dd/yyyy}";
        field5.ApplyFormatInEditMode = true;
        field5.Validators.Add(field5Custom);

        Obout.SuperForm.BoundField field6 = new Obout.SuperForm.BoundField();
        field6.DataField = "HomePhone";
        field6.HeaderText = "Home Phone";
        field6.Required = true;
        field6.Validators.Add(field6Custom);
  
        SuperForm1.Fields.Add(field1);
        SuperForm1.Fields.Add(field2);
        SuperForm1.Fields.Add(field3);
        SuperForm1.Fields.Add(field4);
        SuperForm1.Fields.Add(field5);
        SuperForm1.Fields.Add(field6);

        SuperForm1Container.Controls.Add(SuperForm1);
       
    }
        public void Should_be_valid_when_condition_returns_true()
        {
            var validator = new CustomValidator<Person, int>(v => v%2 == 0);

            Assert.That(validator.Validate(null, 16), Is.True);
        }
Example #41
0
    protected void DeletePostButton_Command(object sender, CommandEventArgs e)
    {
        try
            {
                Service service = new Service();
                service.DeletePost(Convert.ToInt32(e.CommandArgument));
                Response.Redirect("~/Default.aspx");
            }
            catch
            {
                var validator = new CustomValidator
                {
                    IsValid = false,
                    ErrorMessage = "An error occured while deleing post."
                };

                Page.Validators.Add(validator);
            }
    }
        public void InstantiateIn(Control container)
        {
            PlaceHolder templatePlaceHolder = new PlaceHolder();
            container.Controls.Add(templatePlaceHolder);

            Literal div = new Literal();
            div.Text = "<div class=\"Q3\">";

            Obout.Interface.OboutRadioButton radio51 = new Obout.Interface.OboutRadioButton();
            radio51.ID = "OboutRadioButton51";
            radio51.GroupName = "g3";
            radio51.Text = "Strongly Disagree";
            radio51.Width = 125;

            Obout.Interface.OboutRadioButton radio52 = new Obout.Interface.OboutRadioButton();
            radio52.ID = "OboutRadioButton52";
            radio52.GroupName = "g3";
            radio52.Text = "Disagree";
            radio52.Width = 75;

            Obout.Interface.OboutRadioButton radio53 = new Obout.Interface.OboutRadioButton();
            radio53.ID = "OboutRadioButton53";
            radio53.GroupName = "g3";
            radio53.Text = "Agree";
            radio53.Width = 65;

            Obout.Interface.OboutRadioButton radio54 = new Obout.Interface.OboutRadioButton();
            radio54.ID = "OboutRadioButton54";
            radio54.GroupName = "g3";
            radio54.Text = "Strongly Agree";
            radio54.Width = 100;

            CustomValidator customValidator5 = new CustomValidator();
            customValidator5.ID = "CustomValidator5";
            customValidator5.ClientValidationFunction = "validateQuestion5";
            customValidator5.ErrorMessage = "*";

            templatePlaceHolder.Controls.Add(div);
            templatePlaceHolder.Controls.Add(radio51);
            templatePlaceHolder.Controls.Add(radio52);
            templatePlaceHolder.Controls.Add(radio53);
            templatePlaceHolder.Controls.Add(radio54);
            templatePlaceHolder.Controls.Add(customValidator5);

            Literal enddiv = new Literal();
            enddiv.Text = "</div>";

            templatePlaceHolder.Controls.Add(enddiv);
        }
Example #43
0
    /*=========================================================================================================================
      | PAGE INIT
      >==========================================================================================================================
      | Provide handling for functions that must run prior to page load.  This includes dynamically constructed controls.
      \------------------------------------------------------------------------------------------------------------------------*/
    void Page_Init(Object Src, EventArgs E)
    {
        Field.CssClass = "form-control input-sm FormField " + Field.CssClass;

        /*-------------------------------------------------------------------------------------------------------------------------
        | Set dynamic criteria for the input box based on input properties
        \------------------------------------------------------------------------------------------------------------------------*/
          Field.MaxLength = MaxLength;
          if (FieldFontSize > 0) Field.Font.Size = FieldFontSize;

        /*-------------------------------------------------------------------------------------------------------------------------
        | Setup Range Validator
        \------------------------------------------------------------------------------------------------------------------------*/
          if (MinimumValue != null && MaximumValue != null) {
        RangeValidator objValidator = new RangeValidator();
        objValidator.ID = "Range";
        objValidator.Text = "&nbsp;";
        objValidator.ControlToValidate = "Field";

        string error = RangeErrorMessage;
        error = RangeErrorMessage.Replace("%LabelName%", LabelName);
        error = RangeErrorMessage.Replace("%MinimumValue%", MinimumValue);
        error = RangeErrorMessage.Replace("%MaximumValue%", MaximumValue);

        objValidator.ErrorMessage = error;
        objValidator.MinimumValue = MinimumValue.ToString();
        objValidator.MaximumValue = MaximumValue.ToString();

        switch (CompareMethod.ToLower()) {
          case "string":   objValidator.Type = ValidationDataType.String;   break;
          case "integer":  objValidator.Type = ValidationDataType.Integer;  break;
          case "double":   objValidator.Type = ValidationDataType.Double;   break;
          case "date":     objValidator.Type = ValidationDataType.Date;     break;
          case "currency": objValidator.Type = ValidationDataType.Currency; break;
          }

        objValidator.ValidationGroup = ValidationGroup;
        PHRequired.Controls.Add(objValidator);
        }

        /*-------------------------------------------------------------------------------------------------------------------------
        | Setup Email Validator
        \------------------------------------------------------------------------------------------------------------------------*/
          if (ValidateEmail == true) {
        RegularExpressionValidator objValidator = new RegularExpressionValidator();
        objValidator.ID = "Postal";
        objValidator.Text = "&nbsp;";
        objValidator.ControlToValidate = "Field";
        objValidator.ErrorMessage = EmailErrorMessage;
        objValidator.ValidationExpression = @"^[^@]+@[^@]+\.[a-zA-Z]{1,4}$";
        objValidator.ValidationGroup = ValidationGroup;
        PHRequired.Controls.Add(objValidator);
        }

        /*-------------------------------------------------------------------------------------------------------------------------
        | Setup US Postal Validator
        \------------------------------------------------------------------------------------------------------------------------*/
          if (ValidatePostal == true) {
        RegularExpressionValidator objValidator = new RegularExpressionValidator();
        objValidator.ID = "Postal";
        objValidator.Text = "&nbsp;";
        objValidator.ControlToValidate = "Field";
        objValidator.ErrorMessage = PostalErrorMessage;
        objValidator.ValidationExpression = @"^\d{5}$";
        objValidator.ValidationGroup = ValidationGroup;
        PHRequired.Controls.Add(objValidator);
        }

        /*-------------------------------------------------------------------------------------------------------------------------
        | Setup US Phone Validator
        \------------------------------------------------------------------------------------------------------------------------*/
          if (ValidatePhone == true) {
        RegularExpressionValidator objValidator = new RegularExpressionValidator();
        objValidator.ID = "Phone";
        objValidator.Text = "&nbsp;";
        objValidator.ControlToValidate = "Field";
        objValidator.ErrorMessage = PhoneErrorMessage;
        objValidator.ValidationExpression = @"^(\([1-9][0-9]{2}\)\s)+[1-9][0-9]{2}-[0-9]{4}(\sx\s*[0-9]+)?$";
        objValidator.ValidationGroup = ValidationGroup;
        PHRequired.Controls.Add(objValidator);
        }

        /*-------------------------------------------------------------------------------------------------------------------------
        | Setup Max Length Validator
        \------------------------------------------------------------------------------------------------------------------------*/
          if (MaxLength > 0 && TextMode == TextBoxMode.MultiLine) {
        CustomValidator objValidator = new CustomValidator();
        objValidator.ID = "MaxLengthValidator";
        objValidator.Text = "&nbsp;";
        objValidator.ControlToValidate = "Field";

        string error = MaxLengthErrorMessage;
        error = error.Replace("%LabelName%", LabelName);
        error = error.Replace("%MaxLength%", MaxLength.ToString());

        objValidator.ErrorMessage = error;
        objValidator.ServerValidate += new ServerValidateEventHandler(this.CheckLength);
        objValidator.ValidationGroup = ValidationGroup;
        PHRequired.Controls.Add(objValidator);
        }

        /*-------------------------------------------------------------------------------------------------------------------------
        | Setup US Phone Formatter
        \------------------------------------------------------------------------------------------------------------------------*/
          if (FormatPhone) {
        if (!Page.ClientScript.IsStartupScriptRegistered("FormatPhone")) {
          Page.ClientScript.RegisterClientScriptInclude("FormatPhone", "/Common/Global/Client.Scripts/FormatPhone.js");
          }
        OnKeyUp += ";FormatPhone(this);";
        }
    }
	private void AddRow(int index, BXCustomFieldEnum item)
	{
		HtmlTableRow newRow = new HtmlTableRow();

		HtmlTableCell newCell = new HtmlTableCell();
		Label newID = new Label();
		newCell.Controls.Add(newID);
		newRow.Cells.Add(newCell);

		newCell = new HtmlTableCell();
		TextBox newXmlId = new TextBox();
		newXmlId.ID = string.Format("XMLID_{0}", index);
		newXmlId.Columns = 15;
		newCell.Controls.Add(newXmlId);
		CustomValidator newXmlIdValidator = new CustomValidator();
		newXmlIdValidator.ControlToValidate = newXmlId.ID;
		newXmlIdValidator.ValidateEmptyText = true;
		newXmlIdValidator.ValidationGroup = ValidationGroup;
		newXmlIdValidator.ServerValidate += new ServerValidateEventHandler(newXmlIdValidator_ServerValidate);
		newXmlIdValidator.ClientValidationFunction = "customTypeListAdvancedSettings_validateXmlId";
		newXmlIdValidator.Text = "*";
		newXmlIdValidator.ErrorMessage = GetMessage("Message.XmlIdRequired");
		newXmlIdValidator.Display = ValidatorDisplay.Static;
		newCell.Controls.Add(newXmlIdValidator);
		newRow.Cells.Add(newCell);

		newCell = new HtmlTableCell();
		TextBox newValue = new TextBox();
		newValue.ID = string.Format("VALUE_{0}", index);
		newValue.Columns = 35;
		newCell.Controls.Add(newValue);
		CustomValidator newValueValidator = new CustomValidator();
		newValueValidator.ControlToValidate = newValue.ID;
		newValueValidator.ValidateEmptyText = true;
		newValueValidator.ValidationGroup = ValidationGroup;
		newValueValidator.ServerValidate += new ServerValidateEventHandler(newValueValidator_ServerValidate);
		newValueValidator.ClientValidationFunction = "customTypeListAdvancedSettings_validateValue";
		newValueValidator.Text = "*";
		newValueValidator.ErrorMessage = GetMessage("Message.ValueRequired");
		newValueValidator.Display = ValidatorDisplay.Static;
		newCell.Controls.Add(newValueValidator);
		newRow.Cells.Add(newCell);

		valueForXmlId.Add(newXmlIdValidator, newValue);
		xmlIdForValue.Add(newValueValidator, newXmlId);

		newCell = new HtmlTableCell();
		TextBox newSort = new TextBox();
		newSort.ID = string.Format("SORT_{0}", index);
		newSort.Columns = 5;
		newSort.Text = string.Format("{0}", index * 10 + 10);
		newCell.Controls.Add(newSort);
		newRow.Cells.Add(newCell);

		newCell = new HtmlTableCell();
		CheckBox newDefault = new CheckBox();
		newDefault.ID = string.Format("DEFAULT_{0}", index);
		newCell.Controls.Add(newDefault);
		newRow.Cells.Add(newCell);

		newCell = new HtmlTableCell();
		CheckBox newFlag = new CheckBox();
		newFlag.ID = string.Format("FLAG_{0}", index);
		newCell.Controls.Add(newFlag);
		newRow.Cells.Add(newCell);

		if (item != null)
		{
			newID.Text = (item.Id != 0) ? item.Id.ToString() : string.Empty;
			newXmlId.Text = item.XmlId;
			newValue.Text = item.Value;
			newDefault.Checked = item.Default;
		}
		else
		{
			newID.Text = string.Empty;
			newXmlId.Text = string.Empty;
			newValue.Text = string.Empty;
		}
		newFlag.Checked = false;

		ListValue.Rows.Add(newRow);
	}
Example #45
0
        protected override void CreateChildControls()
        {
            _textBox = new TextBox();
            _textBox.ID = this.TextBoxID;
            _textBox.Width = this.Width;
            _textBox.UpdateAfterCallBack = _updateAfterCallBack;

            _hiddenTextBox = new TextBox();
            _hiddenTextBox.ID = this.TextBoxID + "_SelectedValue";
            _hiddenTextBox.UpdateAfterCallBack = _updateAfterCallBack;
            _hiddenTextBox.Style.Add("display", "none");

            this.Controls.Add(_textBox);
            this.Controls.Add(_hiddenTextBox);

            if (Required)
            {
                _validator = new CustomValidator();
                _validator.ID = "val" + this.ID;
                _validator.ControlToValidate = _hiddenTextBox.ID;
                _validator.ErrorMessage = this.ErrorMessage;
                _validator.ValidationGroup = this.ValidationGroup;
                _validator.Display = ValidatorDisplay.Dynamic;
                _validator.ClientValidationFunction = string.Format("{0}ClientValidate", this.ID);
                _validator.ValidateEmptyText = true;
                _validator.ServerValidate += new ServerValidateEventHandler(_validator_ServerValidate);

                Literal literal = new Literal();
                literal.Text = "&nbsp;";

                this.Controls.Add(literal);
                this.Controls.Add(_validator);
            }
        }
        public void Should_be_invalid_when_condition_returns_false()
        {
            var validator = new CustomValidator<Person, int>(v => v % 2 == 0);

            Assert.That(validator.Validate(null, 21), Is.False);
        }
        public void InstantiateIn(Control container)
        {
            PlaceHolder templatePlaceHolder = new PlaceHolder();
            container.Controls.Add(templatePlaceHolder);

            Literal div = new Literal();
            div.Text = "<div class=\"Q4\">";

            Obout.Interface.OboutRadioButton radio81 = new Obout.Interface.OboutRadioButton();
            radio81.ID = "OboutRadioButton81";
            radio81.GroupName = "g6";
            radio81.Text = "Strongly Disagree";
            radio81.Width = 125;

            Obout.Interface.OboutRadioButton radio82 = new Obout.Interface.OboutRadioButton();
            radio82.ID = "OboutRadioButton82";
            radio82.GroupName = "g6";
            radio82.Text = "Disagree";
            radio82.Width = 75;

            Obout.Interface.OboutRadioButton radio83 = new Obout.Interface.OboutRadioButton();
            radio83.ID = "OboutRadioButton83";
            radio83.GroupName = "g6";
            radio83.Text = "Agree";
            radio83.Width = 65;

            Obout.Interface.OboutRadioButton radio84 = new Obout.Interface.OboutRadioButton();
            radio84.ID = "OboutRadioButton84";
            radio84.GroupName = "g6";
            radio84.Text = "Strongly Agree";
            radio84.Width = 100;

            CustomValidator customValidator8 = new CustomValidator();
            customValidator8.ID = "CustomValidator8";
            customValidator8.ClientValidationFunction = "validateQuestion8";
            customValidator8.ErrorMessage = "*";

            templatePlaceHolder.Controls.Add(div);
            templatePlaceHolder.Controls.Add(radio81);
            templatePlaceHolder.Controls.Add(radio82);
            templatePlaceHolder.Controls.Add(radio83);
            templatePlaceHolder.Controls.Add(radio84);
            templatePlaceHolder.Controls.Add(customValidator8);

            Literal enddiv = new Literal();
            enddiv.Text = "</div>";

            templatePlaceHolder.Controls.Add(enddiv);
        }
        public void InstantiateIn(Control container)
        {
            PlaceHolder templatePlaceHolder = new PlaceHolder();
            container.Controls.Add(templatePlaceHolder);

            Literal divQ5 = new Literal();
            divQ5.Text = "<div class=\"Q5\">";

            Literal div = new Literal();
            div.Text = "<div id=\"scaleNumber\">1&#160;&#160;&#160;&#160;2&#160;&#160;&#160;&#160;3&#160;&#160;&#160;&#160;4&#160;&#160;&#160;&#160;5&#160;&#160;&#160;&#160;6</div>";

            Literal unorderlist = new Literal();
            unorderlist.Text = "<ul class=\"no-bullet\" id=\"textArea\">";

            Literal list1 = new Literal();
            list1.Text = "<li>Employee recognition program</li>";

            Literal list2 = new Literal();
            list2.Text = "<li>Ability to make decisions</li>";

            Literal list3 = new Literal();
            list3.Text = "<li>Comfortable work environment</li>";

            Literal list4 = new Literal();
            list4.Text = "<li>Employee training program</li>";

            Literal list5 = new Literal();
            list5.Text = "<li>Company picnic</li>";
            
            Literal list6 = new Literal();
            list6.Text = "<li>Christmas party</li>";

            Literal divRadiosAreas = new Literal();
            divRadiosAreas.Text = "<div id=\"radiosAreas\">";

            Literal div2 = new Literal();
            div2.Text = "<div>";
                        
            Obout.Interface.OboutRadioButton radio91 = new Obout.Interface.OboutRadioButton();
            radio91.ID = "OboutRadioButton91";
            radio91.GroupName = "g7";
            Obout.Interface.OboutRadioButton radio92 = new Obout.Interface.OboutRadioButton();
            radio92.ID = "OboutRadioButton92";
            radio92.GroupName = "g7";
            Obout.Interface.OboutRadioButton radio93 = new Obout.Interface.OboutRadioButton();
            radio93.ID = "OboutRadioButton93";
            radio93.GroupName = "g7";
            Obout.Interface.OboutRadioButton radio94 = new Obout.Interface.OboutRadioButton();
            radio94.ID = "OboutRadioButton94";
            radio94.GroupName = "g7";
            Obout.Interface.OboutRadioButton radio95 = new Obout.Interface.OboutRadioButton();
            radio95.ID = "OboutRadioButton95";
            radio95.GroupName = "g7";
            Obout.Interface.OboutRadioButton radio96 = new Obout.Interface.OboutRadioButton();
            radio96.ID = "OboutRadioButton96";
            radio96.GroupName = "g7";

            CustomValidator customValidator91 = new CustomValidator();
            customValidator91.ID = "CustomValidator91";
            customValidator91.ClientValidationFunction = "validateQuestion91";
            customValidator91.ErrorMessage = "*";

            Literal endDiv2 = new Literal();
            endDiv2.Text = "</div>";

            Literal div3 = new Literal();
            div3.Text = "<div>";
                        
            Obout.Interface.OboutRadioButton radio97 = new Obout.Interface.OboutRadioButton();
            radio97.ID = "OboutRadioButton97";
            radio97.GroupName = "g8";
            Obout.Interface.OboutRadioButton radio98 = new Obout.Interface.OboutRadioButton();
            radio98.ID = "OboutRadioButton98";
            radio98.GroupName = "g8";
            Obout.Interface.OboutRadioButton radio99 = new Obout.Interface.OboutRadioButton();
            radio99.ID = "OboutRadioButton99";
            radio99.GroupName = "g8";
            Obout.Interface.OboutRadioButton radio910 = new Obout.Interface.OboutRadioButton();
            radio910.ID = "OboutRadioButton910";
            radio910.GroupName = "g8";
            Obout.Interface.OboutRadioButton radio911 = new Obout.Interface.OboutRadioButton();
            radio911.ID = "OboutRadioButton911";
            radio911.GroupName = "g8";
            Obout.Interface.OboutRadioButton radio912 = new Obout.Interface.OboutRadioButton();
            radio912.ID = "OboutRadioButton912";
            radio912.GroupName = "g8";

            CustomValidator customValidator92 = new CustomValidator();
            customValidator92.ID = "CustomValidator92";
            customValidator92.ClientValidationFunction = "validateQuestion92";
            customValidator92.ErrorMessage = "*";

            Literal endDiv3 = new Literal();
            endDiv3.Text = "</div>";
         
            Literal div4 = new Literal();
            div4.Text = "<div>";
                        
            Obout.Interface.OboutRadioButton radio913 = new Obout.Interface.OboutRadioButton();
            radio913.ID = "OboutRadioButton913";
            radio913.GroupName = "g9";
            Obout.Interface.OboutRadioButton radio914 = new Obout.Interface.OboutRadioButton();
            radio914.ID = "OboutRadioButton914";
            radio914.GroupName = "g9";
            Obout.Interface.OboutRadioButton radio915 = new Obout.Interface.OboutRadioButton();
            radio915.ID = "OboutRadioButton915";
            radio915.GroupName = "g9";
            Obout.Interface.OboutRadioButton radio916 = new Obout.Interface.OboutRadioButton();
            radio916.ID = "OboutRadioButton916";
            radio916.GroupName = "g9";
            Obout.Interface.OboutRadioButton radio917 = new Obout.Interface.OboutRadioButton();
            radio917.ID = "OboutRadioButton917";
            radio917.GroupName = "g9";
            Obout.Interface.OboutRadioButton radio918 = new Obout.Interface.OboutRadioButton();
            radio918.ID = "OboutRadioButton918";
            radio918.GroupName = "g9";
            
            CustomValidator customValidator93 = new CustomValidator();
            customValidator93.ID = "CustomValidator93";
            customValidator93.ClientValidationFunction = "validateQuestion93";
            customValidator93.ErrorMessage = "*";

            Literal endDiv4 = new Literal();
            endDiv4.Text = "</div>";          
                            
            Literal div5 = new Literal();
            div5.Text = "<div>";
                        
            Obout.Interface.OboutRadioButton radio919 = new Obout.Interface.OboutRadioButton();
            radio919.ID = "OboutRadioButton919";
            radio919.GroupName = "g10";
            Obout.Interface.OboutRadioButton radio920 = new Obout.Interface.OboutRadioButton();
            radio920.ID = "OboutRadioButton920";
            radio920.GroupName = "g10";
            Obout.Interface.OboutRadioButton radio921 = new Obout.Interface.OboutRadioButton();
            radio921.ID = "OboutRadioButton921";
            radio921.GroupName = "g10";
            Obout.Interface.OboutRadioButton radio922 = new Obout.Interface.OboutRadioButton();
            radio922.ID = "OboutRadioButton922";
            radio922.GroupName = "g10";
            Obout.Interface.OboutRadioButton radio923 = new Obout.Interface.OboutRadioButton();
            radio923.ID = "OboutRadioButton923";
            radio923.GroupName = "g10";
            Obout.Interface.OboutRadioButton radio924 = new Obout.Interface.OboutRadioButton();
            radio924.ID = "OboutRadioButton924";
            radio924.GroupName = "g10";

            CustomValidator customValidator94 = new CustomValidator();
            customValidator94.ID = "CustomValidator94";
            customValidator94.ClientValidationFunction = "validateQuestion94";
            customValidator94.ErrorMessage = "*";

            Literal endDiv5 = new Literal();
            endDiv5.Text = "</div>";          
                            
            Literal div6 = new Literal();
            div6.Text = "<div>";
                        
            Obout.Interface.OboutRadioButton radio925 = new Obout.Interface.OboutRadioButton();
            radio925.ID = "OboutRadioButton925";
            radio925.GroupName = "g11";
            Obout.Interface.OboutRadioButton radio926 = new Obout.Interface.OboutRadioButton();
            radio926.ID = "OboutRadioButton926";
            radio926.GroupName = "g11";
            Obout.Interface.OboutRadioButton radio927 = new Obout.Interface.OboutRadioButton();
            radio927.ID = "OboutRadioButton927";
            radio927.GroupName = "g11";
            Obout.Interface.OboutRadioButton radio928 = new Obout.Interface.OboutRadioButton();
            radio928.ID = "OboutRadioButton928";
            radio928.GroupName = "g11";
            Obout.Interface.OboutRadioButton radio929 = new Obout.Interface.OboutRadioButton();
            radio929.ID = "OboutRadioButton929";
            radio929.GroupName = "g11";
            Obout.Interface.OboutRadioButton radio930 = new Obout.Interface.OboutRadioButton();
            radio930.ID = "OboutRadioButton930";
            radio930.GroupName = "g11";
            
            CustomValidator customValidator95 = new CustomValidator();
            customValidator95.ID = "CustomValidator95";
            customValidator95.ClientValidationFunction = "validateQuestion95";
            customValidator95.ErrorMessage = "*";

            Literal endDiv6 = new Literal();
            endDiv6.Text = "</div>";     
                             
            Literal div7 = new Literal();
            div7.Text = "<div>";
                        
            Obout.Interface.OboutRadioButton radio931 = new Obout.Interface.OboutRadioButton();
            radio931.ID = "OboutRadioButton931";
            radio931.GroupName = "g12";
            Obout.Interface.OboutRadioButton radio932 = new Obout.Interface.OboutRadioButton();
            radio932.ID = "OboutRadioButton932";
            radio932.GroupName = "g12";
            Obout.Interface.OboutRadioButton radio933 = new Obout.Interface.OboutRadioButton();
            radio933.ID = "OboutRadioButton933";
            radio933.GroupName = "g12";
            Obout.Interface.OboutRadioButton radio934 = new Obout.Interface.OboutRadioButton();
            radio934.ID = "OboutRadioButton934";
            radio934.GroupName = "g12";
            Obout.Interface.OboutRadioButton radio935 = new Obout.Interface.OboutRadioButton();
            radio935.ID = "OboutRadioButton935";
            radio935.GroupName = "g12";
            Obout.Interface.OboutRadioButton radio936 = new Obout.Interface.OboutRadioButton();
            radio936.ID = "OboutRadioButton936";
            radio936.GroupName = "g12";
            
            CustomValidator customValidator96 = new CustomValidator();
            customValidator96.ID = "CustomValidator96";
            customValidator96.ClientValidationFunction = "validateQuestion96";
            customValidator96.ErrorMessage = "*";

            Literal endDiv7 = new Literal();
            endDiv7.Text = "</div>";

            Literal endDdivQ5 = new Literal();
            endDdivQ5.Text = "</div>";

            Literal endDivRadios = new Literal();
            endDiv7.Text = "</div>";
            
            templatePlaceHolder.Controls.Add(divQ5);
            templatePlaceHolder.Controls.Add(div);
            templatePlaceHolder.Controls.Add(unorderlist);
            templatePlaceHolder.Controls.Add(list1);
            templatePlaceHolder.Controls.Add(list2);
            templatePlaceHolder.Controls.Add(list3);
            templatePlaceHolder.Controls.Add(list4);
            templatePlaceHolder.Controls.Add(list5);
            templatePlaceHolder.Controls.Add(list6);
            templatePlaceHolder.Controls.Add(divRadiosAreas);
            templatePlaceHolder.Controls.Add(div2);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio91);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio92);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio93);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio94);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio95);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio96);
            templatePlaceHolder.Controls.Add(customValidator91);
            templatePlaceHolder.Controls.Add(endDiv2);
            templatePlaceHolder.Controls.Add(div3);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio97);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio98);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio99);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio910);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio911);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio912);
            templatePlaceHolder.Controls.Add(customValidator92);
            templatePlaceHolder.Controls.Add(endDiv3);
            templatePlaceHolder.Controls.Add(div4);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio913);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio914);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio915);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio916);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio917);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio918);
            templatePlaceHolder.Controls.Add(customValidator93);
            templatePlaceHolder.Controls.Add(endDiv4);
            templatePlaceHolder.Controls.Add(div5);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio919);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio920);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio921);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio922);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio923);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio924);
            templatePlaceHolder.Controls.Add(customValidator94);
            templatePlaceHolder.Controls.Add(endDiv5);
            templatePlaceHolder.Controls.Add(div6);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio925);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio926);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio927);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio928);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio929);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio930);
            templatePlaceHolder.Controls.Add(customValidator95);
            templatePlaceHolder.Controls.Add(endDiv6);
            templatePlaceHolder.Controls.Add(div7);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio931);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio932);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio933);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio934);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio935);
            templatePlaceHolder.Controls.Add(CreateSpacer());
            templatePlaceHolder.Controls.Add(radio936);
            templatePlaceHolder.Controls.Add(customValidator96);
            templatePlaceHolder.Controls.Add(endDiv7);
          
            templatePlaceHolder.Controls.Add(endDivRadios);
            templatePlaceHolder.Controls.Add(endDdivQ5);
 
        }
Example #49
0
    private void validateIbanAccountNumber(CustomValidator source, ServerValidateEventArgs value)
    {
        value.IsValid = true;
        //source.ErrorMessage = "If Swift Address is provided , then a Valid Iban Number is Compulsory.";
        //string input = Regex.Replace(this.tbBenefBankAcctNr.Text.ToUpper(), @"\s", "");
        //if ((input.Length == 20) && char.IsLetter(input[0]) && char.IsLetter(input[1]))
        //{
        //    input = input.Substring(4, (input.Length - 4)) + (Convert.ToInt16(input[0]) - 55).ToString() + (Convert.ToInt16(input[1]) - 55).ToString() + input.Substring(2, 2);

        //    int len = Convert.ToInt32((Math.Ceiling(input.Length / 6m)));
        //    input = input.PadRight((6 * len), ' ');
        //    string[] sRebuild = new string[len];
        //    string runner = "00";

        //    for (int i = 0; i < (6 * len); i += 6)
        //    {
        //        runner = (int.Parse((runner + input.Substring(i, 6))) % 97).ToString();
        //    }

        //    value.IsValid = (int.Parse(runner) == 1);
        //}
        //else
        //    value.IsValid = false;
    }
Example #50
0
    private void validateDutchAccountNumber(CustomValidator source, ServerValidateEventArgs value)
    {
        value.IsValid = true;
        //int counter;
        //string bankAcctNr = (string)tbBenefBankAcctNr.Text.Trim();
        //decimal nTotal = 0m;
        //decimal u;

        //if (bankAcctNr[0].ToString().ToUpper() == "P")
        //{
        //    value.IsValid = true; //We cannot validate Postbank accounts yet!!!!
        //    source.ErrorMessage = "We cannot validate Postbank accounts yet!!!!";
        //    return;
        //}

        //if ((bankAcctNr.Length < 9))
        //{
        //    value.IsValid = false;
        //    source.ErrorMessage = "The Beneficiary account number does not appear to be a Valid Dutch Bank account Number";
        //    return;
        //}
        //else if ((bankAcctNr.Length == 9) || (bankAcctNr.Length == 10))
        //{
        //    if (bankAcctNr.Length == 9)
        //    {
        //        bankAcctNr = "0" + bankAcctNr;
        //    }

        //    for (counter = 0; counter < 10; counter++)
        //    {
        //        nTotal = nTotal + Convert.ToDecimal(bankAcctNr.Substring(counter, 1)) * (10 - counter);
        //    }
        //    u = nTotal % 11;
        //    if (u != 0m)
        //    {
        //        value.IsValid = false;
        //        source.ErrorMessage = "The Beneficiary account number failed the 'elfproef' test.";
        //        return;
        //    }
        //    else
        //        value.IsValid = true;
        //}
        //else
        //{
        //    value.IsValid = false;
        //    source.ErrorMessage = "The Beneficiary account number does not appear to be a Valid Dutch Bank account Number";
        //    return;
        //}
    }