public static void CreateCompareValidator(CompareValidator fValidator, Control fControl1, Control fControl2, string fErrorMessage)
 {
     fValidator.ErrorMessage = fErrorMessage;
     fValidator.ControlToCompare = fControl1.ID;
     fValidator.ControlToValidate = fControl2.ID;
     //validator.EnableViewState = false;
     fValidator.ValueToCompare = "=";
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        SuperForm1 = new SuperForm();
        SuperForm1.ID = "SuperForm1"; 
        SuperForm1.Title="Registration Form";
        SuperForm1.AutoGenerateRows = false;
        SuperForm1.AutoGenerateInsertButton = false;
        SuperForm1.AutoGenerateEditButton = false;
        SuperForm1.AutoGenerateDeleteButton = false;
        SuperForm1.DataKeyNames = new string[] { "OrderID" };
        SuperForm1.AllowPaging = false;
        SuperForm1.ItemInserting += SuperForm1_Inserting;
        SuperForm1.DefaultMode = DetailsViewMode.Insert;
            
        CompareValidator compareEmail = new CompareValidator();
        compareEmail.ID="CompareValidator1";
        compareEmail.ValidationGroup="Group1";
        compareEmail.ControlToCompare="SuperForm1_EmailAddress";
        compareEmail.ErrorMessage="*";
        
        Obout.SuperForm.BoundField field1 = new Obout.SuperForm.BoundField();
        field1.DataField = "EmailAddress";
        field1.HeaderText = "E-mail Address";
        field1.Required = true;
        
        Obout.SuperForm.BoundField field2 = new Obout.SuperForm.BoundField();
        field2.DataField = "ConfirmEmailAddress";
        field2.HeaderText = "Confirm E-mail";
        field2.Required = true;
        field2.Validators.Add(compareEmail);

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

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

        Obout.SuperForm.CommandField field5 = new Obout.SuperForm.CommandField();
        field5.ShowInsertButton = true;
        field5.ShowCancelButton = false; 
        field5.ButtonType = ButtonType.Button; 
        field5.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
        field5.HeaderText = "OrderDate";
     
        SuperForm1.Fields.Add(field1);
        SuperForm1.Fields.Add(field2);
        SuperForm1.Fields.Add(field3);
        SuperForm1.Fields.Add(field4);
        SuperForm1.Fields.Add(field5);

        SuperForm1Container.Controls.Add(SuperForm1);

    }
 /// <summary>
 /// 创建比较校验控件
 /// </summary>
 /// <param name="fForm">表单对象</param>
 /// <param name="fControl1"></param>
 /// <param name="fControl2"></param>
 /// <param name="fErrorMessage">提示信息</param>
 public static void CreateCompareValidator(HtmlForm fForm, Control fControl1, Control fControl2, string fErrorMessage)
 {
     CompareValidator validator = new CompareValidator();
     validator.ErrorMessage = fErrorMessage;
     validator.ControlToCompare = fControl1.ID;
     validator.ControlToValidate = fControl2.ID;
     //validator.EnableViewState = false;
     validator.ValueToCompare = "=";
     fForm.Controls.AddAt(fForm.Controls.IndexOf(fControl2) + 1, validator);
 }
Example #4
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init"></see> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.EventArgs"></see> that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            Type         t    = System.Type.GetType(this.Type, true);
            PropertyInfo info = t.GetProperty(_Property);

            object[] attributes = (object[])info.GetCustomAttributes(typeof(BusinessObjectValidationAttribute), false);

            ITextResourceManager resourceManager = null;

            if (!string.IsNullOrEmpty(this.ITextResourceManagerType))
            {
                resourceManager = Activator.CreateInstance(System.Type.GetType(this.ITextResourceManagerType)) as ITextResourceManager;
            }

            // check all attributes
            if (attributes.Length > 0)
            {// at least on attribute exists
                _ValidatorAttribute = attributes[0] as BusinessObjectValidationAttribute;

                if (!string.IsNullOrEmpty(_ValidatorAttribute.Regex))
                {
                    regularExpressionValidator = new RegularExpressionValidator();
                    regularExpressionValidator.ValidationExpression = _ValidatorAttribute.Regex;
                    regularExpressionValidator.ErrorMessage         = (resourceManager != null &&
                                                                       !string.IsNullOrEmpty(_ValidatorAttribute.RegexMessageResourceKey))
                                                                    ? resourceManager.GetResourceText(_ValidatorAttribute.RegexMessageResourceKey)
                                                                    : _ValidatorAttribute.RegexMessage;
                    regularExpressionValidator.ValidationGroup   = this.ValidationGroup;
                    regularExpressionValidator.ControlToValidate = this.ControlToValidate;
                    regularExpressionValidator.Display           = this.Display;
                    regularExpressionValidator.ID = this.ID + REGULAR_EXPRESSION_VALIDATOR_SUFFIX;
                    regularExpressionValidator.EnableClientScript = this.EnableClientScript;
                    this.Controls.Add(regularExpressionValidator);
                }

                if (_ValidatorAttribute.MaxLength >= 0 || _ValidatorAttribute.MinLength >= 0)
                {
                    customStringLengthValidator = new CustomValidator();
                    customStringLengthValidator.ErrorMessage = (resourceManager != null &&
                                                                !string.IsNullOrEmpty(_ValidatorAttribute.OutOfRangeErrorMessageResourceKey))
                                                                    ? resourceManager.GetResourceText(_ValidatorAttribute.OutOfRangeErrorMessageResourceKey)
                                                                    : _ValidatorAttribute.OutOfRangeErrorMessage;
                    customStringLengthValidator.ValidationGroup   = this.ValidationGroup;
                    customStringLengthValidator.ControlToValidate = this.ControlToValidate;
                    customStringLengthValidator.Display           = this.Display;
                    customStringLengthValidator.ID = this.ID + CUSTOM_STRING_LENGTH_VALIDATOR_SUFFIX;
                    customStringLengthValidator.EnableClientScript = this.EnableClientScript;
                    customStringLengthValidator.ValidateEmptyText  = true;
                    customStringLengthValidator.ServerValidate    += new ServerValidateEventHandler(customStringLengthValidator_ServerValidate);
                    this.Controls.Add(customStringLengthValidator);
                }

                if (!string.IsNullOrEmpty(_ValidatorAttribute.MinimumValue) || !string.IsNullOrEmpty(_ValidatorAttribute.MaximumValue))
                {
                    rangeValidator = new RangeValidator();
                    rangeValidator.MinimumValue = _ValidatorAttribute.MinimumValue;
                    rangeValidator.MaximumValue = _ValidatorAttribute.MaximumValue;
                    rangeValidator.ErrorMessage = (resourceManager != null &&
                                                   !string.IsNullOrEmpty(_ValidatorAttribute.OutOfRangeErrorMessageResourceKey))
                                                                    ? resourceManager.GetResourceText(_ValidatorAttribute.OutOfRangeErrorMessageResourceKey)
                                                                    : _ValidatorAttribute.OutOfRangeErrorMessage;
                    rangeValidator.ControlToValidate = this.ControlToValidate;
                    rangeValidator.Display           = this.Display;
                    rangeValidator.ID = this.ID + RANGE_VALIDATOR_SUFFIX;
                    rangeValidator.EnableClientScript = this.EnableClientScript;
                    rangeValidator.Type = this.RangeValidationDataType;
                    this.Controls.Add(rangeValidator);
                }

                if (_ValidatorAttribute.IsRequired)
                {
                    requiredFieldValidator = new RequiredFieldValidator();
                    requiredFieldValidator.ControlToValidate = this.ControlToValidate;
                    requiredFieldValidator.Display           = this.Display;
                    requiredFieldValidator.ErrorMessage      = (resourceManager != null &&
                                                                !string.IsNullOrEmpty(_ValidatorAttribute.IsRequiredMessageResourceKey))
                                                                    ? resourceManager.GetResourceText(_ValidatorAttribute.IsRequiredMessageResourceKey)
                                                                    : _ValidatorAttribute.IsRequiredMessage;
                    requiredFieldValidator.ID = this.ID + REQUIRED_FIELD_VALIDATOR_SUFFIX;
                    requiredFieldValidator.EnableClientScript = this.EnableClientScript;
                    this.Controls.Add(requiredFieldValidator);
                }

                if (!string.IsNullOrEmpty(this.ControlToCompare))
                {
                    compareValidator = new CompareValidator();
                    compareValidator.ControlToCompare  = this.ControlToCompare;
                    compareValidator.ControlToValidate = this.ControlToValidate;
                    compareValidator.Display           = this.Display;
                    compareValidator.ID = this.ID + COMPARE_VALIDATOR_SUFFIX;
                    compareValidator.EnableClientScript = this.EnableClientScript;
                    this.Controls.Add(compareValidator);
                }
            }
        }
    protected void Page_Load(object sender, System.EventArgs e)
    {
        int numcells = 6;
        int j;

        TableRow HeaderRow = new TableRow();
        HeaderRow.Style["color"] = "white";
        HeaderRow.Style["font-weight"] = "bold";
        HeaderRow.Style["text-align"] = "center";
        HeaderRow.Style["background-color"] = "#5D7B9D";
        tbAnos.Rows.Add(HeaderRow);

        //-- Add header cells to the row
        TableCell HeaderCell_1 = new TableCell();
        HeaderCell_1.Text = "Ano";
        HeaderRow.Cells.Add(HeaderCell_1);

        TableCell HeaderCellP_1 = new TableCell();
        HeaderCellP_1.Text = "1º Trim";
        HeaderRow.Cells.Add(HeaderCellP_1);

        TableCell HeaderCellP_2 = new TableCell();
        HeaderCellP_2.Text = "2º Trim";
        HeaderRow.Cells.Add(HeaderCellP_2);

        TableCell HeaderCellP_3 = new TableCell();
        HeaderCellP_3.Text = "3º Trim";
        HeaderRow.Cells.Add(HeaderCellP_3);

        TableCell HeaderCellP_4 = new TableCell();
        HeaderCellP_4.Text = "4º Trim";
        HeaderRow.Cells.Add(HeaderCellP_4);

        TableCell HeaderCell_5 = new TableCell();
        HeaderCell_5.Text = "Total";
        HeaderRow.Cells.Add(HeaderCell_5);
        if (_editar)
            HeaderCell_5.Visible = false;

        t08_acao t08 = new t08_acao();
        t08.t08_cd_acao = pb.cd_acao();
        t08.Retrieve();
        if (t08.Found)
        {
            for (j = t08.dt_inicio.Year; j <= t08.dt_fim.Year; j++)
            {
                TableRow r = new TableRow();
                r.Style["background-color"] = "#F1F5F5";
                int i;
                for (i = 0; i <= numcells - 1; i++)
                {
                    TableCell c = new TableCell();
                    TextBox UserTextBox = new TextBox();
                    if (!_editar)
                    {

                        UserTextBox.Attributes.Add("style", "background:#F1F5F5;border:none;text-align:right;");
                        UserTextBox.ReadOnly = true;
                    }
                    CompareValidator val = new CompareValidator();
                    switch (i)
                    {
                        case 0:
                            //ANO
                            c.Controls.Add(new LiteralControl(j.ToString()));
                            r.Cells.Add(c);
                            break;
                        case 1:
                            //PREVISTO

                            UserTextBox.ID = "txtvl_p" + i.ToString() + j.ToString();
                            UserTextBox.Columns = 18;
                            UserTextBox.MaxLength = 18;
                            UserTextBox.EnableViewState = true;
                            UserTextBox.Text = "0";

                            val.ID = "valp" + i.ToString() + j.ToString();
                            val.ControlToValidate = UserTextBox.ID;
                            val.ErrorMessage = "<br>*formato inválido";
                            val.Display = ValidatorDisplay.Dynamic;
                            val.Operator = ValidationCompareOperator.DataTypeCheck;
                            val.Type = ValidationDataType.Currency;
                            c.Controls.Add(UserTextBox);
                            c.Controls.Add(val);
                            r.Cells.Add(c);

                            break;
                        case 2:
                            //PREVISTO

                            UserTextBox.ID = "txtvl_p" + i.ToString() + j.ToString();
                            UserTextBox.Columns = 18;
                            UserTextBox.MaxLength = 18;
                            UserTextBox.EnableViewState = true;
                            UserTextBox.Text = "0";

                            val.ID = "valp" + i.ToString() + j.ToString();
                            val.ControlToValidate = UserTextBox.ID;
                            val.ErrorMessage = "<br>*formato inválido";
                            val.Display = ValidatorDisplay.Dynamic;
                            val.Operator = ValidationCompareOperator.DataTypeCheck;
                            val.Type = ValidationDataType.Currency;
                            c.Controls.Add(UserTextBox);
                            c.Controls.Add(val);
                            r.Cells.Add(c);

                            break;
                        case 3:
                            //PREVISTO

                            UserTextBox.ID = "txtvl_p" + i.ToString() + j.ToString();
                            UserTextBox.Columns = 18;
                            UserTextBox.MaxLength = 18;
                            UserTextBox.EnableViewState = true;
                            UserTextBox.Text = "0";

                            val.ID = "valp" + i.ToString() + j.ToString();
                            val.ControlToValidate = UserTextBox.ID;
                            val.ErrorMessage = "<br>*formato inválido";
                            val.Display = ValidatorDisplay.Dynamic;
                            val.Operator = ValidationCompareOperator.DataTypeCheck;
                            val.Type = ValidationDataType.Currency;
                            c.Controls.Add(UserTextBox);
                            c.Controls.Add(val);
                            r.Cells.Add(c);

                            break;
                        case 4:
                            //PREVISTO

                            UserTextBox.ID = "txtvl_p" + i.ToString() + j.ToString();
                            UserTextBox.Columns = 18;
                            UserTextBox.MaxLength = 18;
                            UserTextBox.EnableViewState = true;
                            UserTextBox.Text = "0";

                            val.ID = "valp" + i.ToString() + j.ToString();
                            val.ControlToValidate = UserTextBox.ID;
                            val.ErrorMessage = "<br>*formato inválido";
                            val.Display = ValidatorDisplay.Dynamic;
                            val.Operator = ValidationCompareOperator.DataTypeCheck;
                            val.Type = ValidationDataType.Currency;
                            c.Controls.Add(UserTextBox);
                            c.Controls.Add(val);
                            r.Cells.Add(c);

                            break;
                        case 5:
                            //PREVISTO TOTAL

                            UserTextBox.ID = "txtvl_ptotal" + i.ToString() + j.ToString();
                            UserTextBox.Columns = 18;
                            UserTextBox.MaxLength = 18;
                            UserTextBox.EnableViewState = true;
                            UserTextBox.Text = "0,00";
                            UserTextBox.ReadOnly = true;
                            if (!_editar)
                            {
                                c.Controls.Add(UserTextBox);
                                r.Cells.Add(c);
                            }
                            break;

                    }

                }
                tbAnos.Rows.Add(r);
            }
        }
    }
Example #6
0
        protected override void CreateChildControls()
        {
            if (IsListControl())
            {
                base.CreateChildControls();
                return;
            }

            switch (Type)
            {
            case DataFieldType.DateRange:
                this.Controls.Add(txtFirst);

                txtFirst.ID              = "txtFrom";
                txtFirst.MaxLength       = 10;
                txtFirst.TabIndex        = 0;
                txtFirst.ValidationGroup = ValidationGroup;

                AddDataTypeValidation(txtFirst, ValidationDataType.Date);

                this.Controls.Add(new LiteralControl("&nbsp;al&nbsp;"));

                this.Controls.Add(txtSecond);

                txtSecond.ID              = "txtTo";
                txtSecond.MaxLength       = 10;
                txtSecond.TabIndex        = 0;
                txtSecond.ValidationGroup = ValidationGroup;

                AddDataTypeValidation(txtSecond, ValidationDataType.Date);

                CompareValidator cv = new CompareValidator();
                this.Controls.Add(cv);
                cv.ControlToValidate = txtSecond.ID;
                cv.ControlToCompare  = txtFirst.ID;
                cv.Operator          = ValidationCompareOperator.GreaterThan;
                cv.Type            = ValidationDataType.Date;
                cv.Display         = ValidatorDisplay.Dynamic;
                cv.Text            = Resources.Controls.Validator_Range;
                cv.ValidationGroup = ValidationGroup;
                cv.CssClass        = ValidationCssClass;

                CalendarExtender ce = new AjaxControlToolkit.CalendarExtender();
                this.Controls.Add(ce);
                ce.TargetControlID = txtFirst.ID;

                ce = new AjaxControlToolkit.CalendarExtender();
                this.Controls.Add(ce);
                ce.TargetControlID = txtSecond.ID;

                break;

            case DataFieldType.Label:
                this.Controls.Add(lblFirst);
                lblFirst.ID = "lblFirst";
                break;

            case DataFieldType.HyperLink:
                this.Controls.Add(hypFirst);
                hypFirst.ID = "hypFirst";
                break;

            case DataFieldType.CheckBox:
                this.Controls.Add(chkFirst);
                chkFirst.ID              = "chkFirst";
                chkFirst.AutoPostBack    = AutoPostBack;
                chkFirst.CheckedChanged += new EventHandler(chkFirst_CheckedChanged);

                AddCheckBoxValidation(chkFirst);

                break;

            default:
                this.Controls.Add(txtFirst);

                txtFirst.ID              = "txtFrom";
                txtFirst.MaxLength       = MaxLength;
                txtFirst.TabIndex        = TabIndex;
                txtFirst.ValidationGroup = ValidationGroup;
                txtFirst.AutoPostBack    = this.AutoPostBack;
                txtFirst.TextChanged    += new EventHandler(txtFirst_TextChanged);
                AddRequiredValidation(txtFirst);

                switch (Type)
                {
                case DataFieldType.Number:
                    if (NumberType == DataNumberType.Integer)
                    {
                        txtFirst.CssClass = "integer";
                        AddDataTypeValidation(txtFirst, ValidationDataType.Integer);
                    }
                    else
                    {
                        txtFirst.CssClass = "currency";
                        AddDataTypeValidation(txtFirst, ValidationDataType.Currency);
                    }

                    break;

                case DataFieldType.Date:
                    txtFirst.CssClass = "date";
                    AddDataTypeValidation(txtFirst, ValidationDataType.Date);
                    break;

                case DataFieldType.Email:
                    AddEmailValidation(txtFirst);
                    break;

                case DataFieldType.LongText:
                    txtFirst.TextMode = TextBoxMode.MultiLine;
                    txtFirst.Rows     = 10;
                    txtFirst.Columns  = 40;
                    break;

                case DataFieldType.HtmlEditor:
                    txtFirst.CssClass = "mceEditor";
                    txtFirst.TextMode = TextBoxMode.MultiLine;
                    txtFirst.Rows     = 20;
                    txtFirst.Columns  = 60;
                    break;
                }

                break;
            }
        }
        /// <summary>
        /// Create campaign Fields controls dynamically
        /// </summary>
        private void CreateCampaignFields()
        {
            HtmlTableRow  trData;
            HtmlTableCell tdLabel;
            HtmlTableCell tdTextBox;

            DataSet dsCampaignFields;

            dsCampaignFields = (DataSet)Session["CampaignFields"]; // campaign fields

            try
            {
                if (dsCampaignFields != null)
                {
                    if (dsCampaignFields.Tables.Count > 0)
                    {
                        string strFieldName   = string.Empty;
                        string strFieldType   = string.Empty;
                        int    intFieldLength = 0;

                        for (int i = 0; i < dsCampaignFields.Tables[0].Rows.Count; i++)
                        {
                            strFieldName   = dsCampaignFields.Tables[0].Rows[i]["FieldName"].ToString();
                            strFieldType   = dsCampaignFields.Tables[0].Rows[i]["FieldType"].ToString();
                            intFieldLength = strFieldType == "String" ? Convert.ToInt32(dsCampaignFields.Tables[0].Rows[i]["Value"]) : 10;


                            // Begin  Code for Creating controls dynamically

                            trData    = new HtmlTableRow();
                            trData.ID = "tr" + i.ToString();

                            tdLabel           = new HtmlTableCell();
                            tdLabel.ID        = "tdl" + i.ToString();
                            tdLabel.Align     = "right";
                            tdLabel.InnerHtml = "<b>" + strFieldName + "&nbsp;:&nbsp;</b>";

                            txtControl = new TextBox();

                            // td  text box
                            tdTextBox    = new HtmlTableCell();
                            tdTextBox.ID = "tdt" + i.ToString();

                            // text box
                            txtControl.ID        = "txt" + strFieldName;
                            txtControl.Visible   = true;
                            txtControl.CssClass  = "txtnormal";
                            txtControl.MaxLength = intFieldLength;
                            txtControl.Text      = "";

                            if (strFieldName == "PHONENUM")
                            {
                                txtControl.ReadOnly = true;
                            }

                            // td text boxes
                            tdTextBox.InnerHtml = "&nbsp;";
                            tdTextBox.Align     = "left";
                            tdTextBox.Controls.Add(txtControl);

                            if (strFieldType != "Date")
                            {
                                cmpControl                   = new CompareValidator();
                                cmpControl.ID                = "cmp" + strFieldName;
                                cmpControl.Operator          = ValidationCompareOperator.DataTypeCheck;
                                cmpControl.ControlToValidate = "txt" + strFieldName;
                                cmpControl.ErrorMessage      = "Please enter valid " + strFieldName;
                                cmpControl.Text              = "*";
                                cmpControl.Display           = ValidatorDisplay.Static;
                                cmpControl.SetFocusOnError   = true;
                                switch (strFieldType)
                                {
                                case "Decimal":
                                    cmpControl.Type = ValidationDataType.Double;
                                    break;

                                case "Money":
                                    cmpControl.Type = ValidationDataType.Double;
                                    break;

                                case "Integer":
                                    cmpControl.Type = ValidationDataType.Integer;
                                    break;

                                case "String":
                                    cmpControl.Type = ValidationDataType.String;
                                    break;
                                }
                                tdTextBox.Controls.Add(cmpControl);
                            }

                            //add new row with label and text box
                            trData.Controls.Add(tdLabel);
                            trData.Controls.Add(tdTextBox);

                            // add new row to table
                            tbData.Controls.Add(trData);

                            //  End code
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                PageMessage = ex.Message;
            }
        }
Example #8
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // Ederon : guess we don't need to test CanLogin anymore
            if (/*!CanLogin ||*/ PageContext.BoardSettings.DisableRegistrations)
            {
                YafBuildLink.AccessDenied();
            }

            if (!IsPostBack)
            {
                PageLinks.AddLink(PageContext.BoardSettings.Name, YAF.Classes.Utils.YafBuildLink.GetLink(YAF.Classes.Utils.ForumPages.forum));
                PageLinks.AddLink(GetText("TITLE"));

                // handle the CreateUser Step localization
                Control createUserTemplateRef = CreateUserWizard1.CreateUserStep.ContentTemplateContainer;

                CompareValidator       passwordNoMatch         = (CompareValidator)createUserTemplateRef.FindControl("PasswordCompare");
                RequiredFieldValidator usernameRequired        = (RequiredFieldValidator)createUserTemplateRef.FindControl("UserNameRequired");
                RequiredFieldValidator passwordRequired        = (RequiredFieldValidator)createUserTemplateRef.FindControl("PasswordRequired");
                RequiredFieldValidator confirmPasswordRequired = (RequiredFieldValidator)createUserTemplateRef.FindControl("ConfirmPasswordRequired");
                RequiredFieldValidator emailRequired           = (RequiredFieldValidator)createUserTemplateRef.FindControl("EmailRequired");
                RequiredFieldValidator questionRequired        = (RequiredFieldValidator)createUserTemplateRef.FindControl("QuestionRequired");
                RequiredFieldValidator answerRequired          = (RequiredFieldValidator)createUserTemplateRef.FindControl("AnswerRequired");
                Button createUser = (Button)createUserTemplateRef.FindControl("StepNextButton");

                usernameRequired.ToolTip        = usernameRequired.ErrorMessage = GetText("NEED_USERNAME");
                passwordRequired.ToolTip        = passwordRequired.ErrorMessage = GetText("NEED_PASSWORD");
                confirmPasswordRequired.ToolTip = confirmPasswordRequired.ErrorMessage = GetText("RETYPE_PASSWORD");
                passwordNoMatch.ToolTip         = passwordNoMatch.ErrorMessage = GetText("NEED_MATCH");
                emailRequired.ToolTip           = emailRequired.ErrorMessage = GetText("NEED_EMAIL");
                questionRequired.ToolTip        = questionRequired.ErrorMessage = GetText("NEED_QUESTION");
                answerRequired.ToolTip          = answerRequired.ErrorMessage = GetText("NEED_ANSWER");
                createUser.ToolTip = createUser.Text = GetText("CREATE_USER");

                // handle other steps localization
                ((Button)FindWizardControl("ProfileNextButton")).Text = GetText("SAVE");
                ((Button)FindWizardControl("ContinueButton")).Text    = GetText("CONTINUE");

                // get the time zone data source
                DropDownList timeZones = ((DropDownList)FindWizardControl("TimeZones"));
                timeZones.DataSource = YafStaticData.TimeZones();

                if (!PageContext.BoardSettings.EmailVerification)
                {
                    // automatically log in created users
                    CreateUserWizard1.LoginCreatedUser   = true;
                    CreateUserWizard1.DisableCreatedUser = false;
                    // success notification localization
                    ((Literal)FindWizardControl("AccountCreated")).Text = YAF.Classes.UI.BBCode.MakeHtml(GetText("ACCOUNT_CREATED"), true, false);
                }
                else
                {
                    CreateUserWizard1.LoginCreatedUser   = false;
                    CreateUserWizard1.DisableCreatedUser = true;
                    // success notification localization
                    ((Literal)FindWizardControl("AccountCreated")).Text = YAF.Classes.UI.BBCode.MakeHtml(GetText("ACCOUNT_CREATED_VERIFICATION"), true, false);
                }

                if (PageContext.BoardSettings.EnableCaptchaForRegister)
                {
                    Session["CaptchaImageText"] = General.GetCaptchaString();
                    Image       imgCaptcha         = (Image)createUserTemplateRef.FindControl("imgCaptcha");
                    PlaceHolder captchaPlaceHolder = ( PlaceHolder )createUserTemplateRef.FindControl("CaptchaPlaceHolder");

                    imgCaptcha.ImageUrl        = String.Format("{0}resource.ashx?c=1", YafForumInfo.ForumRoot);
                    captchaPlaceHolder.Visible = true;
                }

                PlaceHolder questionAnswerPlaceHolder = ( PlaceHolder )createUserTemplateRef.FindControl("QuestionAnswerPlaceHolder");
                questionAnswerPlaceHolder.Visible = Membership.RequiresQuestionAndAnswer;

                CreateUserWizard1.FinishDestinationPageUrl = YafForumInfo.ForumURL;

                DataBind();

                timeZones.Items.FindByValue("0").Selected = true;
            }
        }
        private static void ApplyValidations(ref Control oControl, ref UserControl oParentControl, UIControl oUIControl)
        {
            if (oControl != null)
            {
                System.Type oControlType = oControl.GetType();

                switch (oControlType.Name.ToUpper())
                {
                case "TEXTBOX":
                    TextBox tb = (TextBox)oControl;
                    tb.ToolTip = oUIControl.ToolTipText;

                    //Required field validator
                    if (oUIControl.ValidationRequired == 1)
                    {
                        if (oParentControl.FindControl("rfv" + oUIControl.ControlName) == null)
                        {
                            RequiredFieldValidator oRFV = new RequiredFieldValidator();
                            oRFV.ID = "rfv" + oUIControl.ControlName;
                            oRFV.ControlToValidate = oUIControl.ControlName;
                            oRFV.Display           = ValidatorDisplay.None;

                            if (oUIControl.ValidationMsg != "")
                            {
                                oRFV.ErrorMessage = oUIControl.ValidationMsg;
                            }
                            else
                            {
                                oRFV.ErrorMessage = oUIControl.ShortName + " : " + "Please enter " + oUIControl.LabelText;
                            }

                            oParentControl.Controls.Add(oRFV);
                            oRFV.SetFocusOnError = true;
                        }
                    }
                    //Regular Expression Validation (if not exists add  OR if exists not required remove)
                    if (oUIControl.ValidationRegularExp != null && oUIControl.ValidationRegularExp.RegularExpId > 0)
                    {
                        if (oParentControl.FindControl("rev" + oUIControl.ControlName) == null)
                        {
                            RegularExpressionValidator oREV = new RegularExpressionValidator();
                            oREV.ID = "rev" + oUIControl.ControlName;
                            oREV.ControlToValidate    = oUIControl.ControlName;
                            oREV.ValidationExpression = oUIControl.ValidationRegularExp.RegularExp;
                            oREV.Display = ValidatorDisplay.None;

                            oREV.ErrorMessage = oUIControl.ShortName + " : " + oUIControl.ValidationRegularExp.DefaultMsg;

                            oParentControl.Controls.Add(oREV);
                            oREV.SetFocusOnError = true;
                        }
                    }
                    //Range Validation
                    if (oUIControl.ValidationRangeFrom != "" && oUIControl.ValidationRangeTo != "")
                    {
                        if (oParentControl.FindControl("rv" + oUIControl.ControlName) == null)
                        {
                            RangeValidator oRV = new RangeValidator();
                            oRV.ID = "rv" + oUIControl.ControlName;
                            oRV.ControlToValidate = oUIControl.ControlName;
                            oRV.MinimumValue      = oUIControl.ValidationRangeFrom.ToString();
                            oRV.MaximumValue      = oUIControl.ValidationRangeTo.ToString();
                            if (oUIControl.ControlDataType.DataTypeId == 1)     //String
                            {
                                oRV.Type = ValidationDataType.String;
                            }
                            else if (oUIControl.ControlDataType.DataTypeId == 2)     //Integer
                            {
                                oRV.Type = ValidationDataType.Integer;
                            }
                            else if (oUIControl.ControlDataType.DataTypeId == 3)    //Double
                            {
                                oRV.Type = ValidationDataType.Double;
                            }
                            else if (oUIControl.ControlDataType.DataTypeId == 4)    //Currency
                            {
                                oRV.Type = ValidationDataType.Currency;
                            }
                            else if (oUIControl.ControlDataType.DataTypeId == 5)    //Date
                            {
                                oRV.Type = ValidationDataType.Date;
                            }

                            oRV.Display = ValidatorDisplay.None;

                            oRV.ErrorMessage = oUIControl.ShortName + " : " + "Please enter " + oUIControl.ShortName + " value from " + oUIControl.ValidationRangeFrom.ToString() + " to " + oUIControl.ValidationRangeTo.ToString();

                            oParentControl.Controls.Add(oRV);
                            oRV.SetFocusOnError = true;
                        }
                    }
                    //Length Validation
                    if (oUIControl.ValidationMinLen > 0 && oUIControl.ValidationMinLen > 0)
                    {
                        if (oParentControl.FindControl("revlen" + oUIControl.ControlName) == null)
                        {
                            RegularExpressionValidator oREV = new RegularExpressionValidator();
                            oREV.ID = "revlen" + oUIControl.ControlName;
                            oREV.ControlToValidate    = oUIControl.ControlName;
                            oREV.ValidationExpression = "^.{" + oUIControl.ValidationMinLen + "," + oUIControl.ValidationMaxLen + "}$";
                            oREV.Display      = ValidatorDisplay.None;
                            oREV.ErrorMessage = oUIControl.ShortName + " : " + "It must be between " + oUIControl.ValidationMinLen.ToString() + " and " + oUIControl.ValidationMaxLen.ToString() + " characters";
                            oParentControl.Controls.Add(oREV);
                            oREV.SetFocusOnError = true;
                        }
                    }

                    //Client Valdiation Using Client Side Validation
                    if (oUIControl.ValidationCustomClientSideFunction != "")
                    {
                        if (oParentControl.FindControl("customValClientSide" + oUIControl.ControlName) == null)
                        {
                            CustomValidator ocustomValClientSide = new CustomValidator();
                            ocustomValClientSide.ID = "customValClientSide" + oUIControl.ControlName;
                            ocustomValClientSide.ControlToValidate        = oUIControl.ControlName;
                            ocustomValClientSide.ClientValidationFunction = oUIControl.ValidationCustomClientSideFunction;
                            ocustomValClientSide.Display      = ValidatorDisplay.None;
                            ocustomValClientSide.ErrorMessage = oUIControl.ShortName + " : " + oUIControl.ValidationMsg;
                            oParentControl.Controls.Add(ocustomValClientSide);
                            ocustomValClientSide.SetFocusOnError = true;
                        }
                    }

                    // //Custom Valdiation Using Server Side Validation -Not working for onServerValidate
                    //if (oUIControl.ValidationCustomServerSideFunction != "" )
                    //{
                    //    if (oParentControl.FindControl("customValServerSide" + oUIControl.ControlName) == null)
                    //    {
                    //        CustomValidator ocustomValServerSide = new CustomValidator();
                    //        ocustomValServerSide.ID = "customValServerSide" + oUIControl.ControlName;
                    //        ocustomValServerSide.ControlToValidate = oUIControl.ControlName;
                    //        ocustomValServerSide.onServerValidate = oUIControl.ValidationCustomServerSideFunction;
                    //        ocustomValServerSide.Display = ValidatorDisplay.None;
                    //        ocustomValServerSide.ErrorMessage = oUIControl.ShortName + " : " + oUIControl.ValidationMsg;
                    //        oParentControl.Controls.Add(ocustomValServerSide);
                    //        ocustomValServerSide.SetFocusOnError = true;
                    //    }
                    //}

                    //Compare Validation
                    if (oUIControl.ValidationCompareControl != "")
                    {
                        if (oParentControl.FindControl("compVal" + oUIControl.ControlName) == null)
                        {
                            CompareValidator oCompareValidator = new CompareValidator();
                            oCompareValidator.ID = "compVal" + oUIControl.ControlName;
                            oCompareValidator.ControlToValidate = oUIControl.ControlName;
                            oCompareValidator.ControlToCompare  = oUIControl.ValidationCompareControl;
                            oCompareValidator.Display           = ValidatorDisplay.None;
                            oCompareValidator.ErrorMessage      = oUIControl.ShortName + " : " + oUIControl.ValidationMsg;
                            oParentControl.Controls.Add(oCompareValidator);
                            oCompareValidator.SetFocusOnError = true;
                        }
                    }

                    break;

                case "DROPDOWNLIST":
                    DropDownList ddl = (DropDownList)oControl;
                    ddl.ToolTip = oUIControl.ToolTipText;
                    if (oUIControl.ValidationRequired == 1)
                    {
                        if (oParentControl.FindControl("rfv" + oUIControl.ControlName) == null)
                        {
                            RequiredFieldValidator oRFV = new RequiredFieldValidator();
                            oRFV.ID = "rfv" + oUIControl.ControlName;
                            oRFV.ControlToValidate = oUIControl.ControlName;
                            oRFV.Display           = ValidatorDisplay.None;
                            oRFV.InitialValue      = "-1";
                            //oRFV.ErrorMessage = oUIControl.ValidationMsg;
                            oRFV.ErrorMessage = oUIControl.ShortName + " : " + "Please select " + oUIControl.LabelText;
                            oParentControl.Controls.Add(oRFV);
                            oRFV.SetFocusOnError = true;
                        }
                    }
                    break;

                case "RADIOBUTTONLIST":
                    RadioButtonList oOptButtonList = (RadioButtonList)oControl;
                    oOptButtonList.ToolTip = oUIControl.ToolTipText;
                    if (oUIControl.ValidationRequired == 1)
                    {
                        if (oParentControl.FindControl("rfv" + oUIControl.ControlName) == null)
                        {
                            RequiredFieldValidator oRFV = new RequiredFieldValidator();
                            oRFV.ID = "rfv" + oUIControl.ControlName;
                            oRFV.ControlToValidate = oUIControl.ControlName;
                            oRFV.Display           = ValidatorDisplay.None;
                            oRFV.InitialValue      = "";
                            if (oUIControl.ValidationMsg == "")
                            {
                                oRFV.ErrorMessage = oUIControl.ShortName + " : " + "Please select " + oUIControl.LabelText;
                            }
                            else
                            {
                                oRFV.ErrorMessage = oUIControl.ValidationMsg;
                            }

                            oParentControl.Controls.Add(oRFV);
                            oRFV.SetFocusOnError = true;
                        }
                    }
                    break;

                case "LISTBOX":
                    ListBox oListBox = (ListBox)oControl;
                    oListBox.ToolTip = oUIControl.ToolTipText;
                    if (oUIControl.ValidationRequired == 1)
                    {
                        if (oParentControl.FindControl("rfv" + oUIControl.ControlName) == null)
                        {
                            RequiredFieldValidator oRFV = new RequiredFieldValidator();
                            oRFV.ID = "rfv" + oUIControl.ControlName;
                            oRFV.ControlToValidate = oUIControl.ControlName;
                            oRFV.Display           = ValidatorDisplay.None;
                            oRFV.InitialValue      = "-1";
                            if (oUIControl.ValidationMsg == "")
                            {
                                oRFV.ErrorMessage = oUIControl.ShortName + " : " + "Please select " + oUIControl.LabelText;
                            }
                            else
                            {
                                oRFV.ErrorMessage = oUIControl.ValidationMsg;
                            }

                            oParentControl.Controls.Add(oRFV);
                            oRFV.SetFocusOnError = true;
                        }
                    }

                    break;

                case "BUTTON":
                    Button btn = (Button)oControl;
                    btn.ToolTip = oUIControl.ToolTipText;
                    //btn.Text = oUIControl.LabelText;
                    break;

                case "LINKBUTTON":
                    LinkButton lbtn = (LinkButton)oControl;
                    lbtn.ToolTip = oUIControl.ToolTipText;
                    //lbtn.Text = oUIControl.LabelText;
                    break;

                case "CHECKBOX":
                    CheckBox chk = (CheckBox)oControl;
                    chk.ToolTip = oUIControl.ToolTipText;
                    //chk.Text = oUIControl.LabelText;
                    break;

                case "RADIOBUTTON":
                    RadioButton optBtn = (RadioButton)oControl;
                    optBtn.ToolTip = oUIControl.ToolTipText;
                    //optBtn.Text = oUIControl.LabelText;
                    break;
                }
                ;
            }
        }
Example #10
0
        protected void gvResult_ItemCreated(object source, DataGridItemEventArgs e)
        {
            if ((e.Item.ItemType == ListItemType.EditItem))
            {
                CompareValidator comValDates_gd = new CompareValidator();
                comValDates_gd.ErrorMessage      = "<br/>Start Date cannot be greater than End Date.";
                comValDates_gd.ControlToCompare  = "txtStartDate_gd";
                comValDates_gd.ControlToValidate = "txtEndDate_gd";
                comValDates_gd.ValidationGroup   = "EditVal";
                comValDates_gd.Display           = ValidatorDisplay.Dynamic;
                comValDates_gd.Type     = ValidationDataType.Date;
                comValDates_gd.Operator = ValidationCompareOperator.GreaterThan;

                if (e.Item.Cells[5].Controls[0] is Button)
                {
                    Button l_btnUpdate = ((Button)e.Item.Cells[5].Controls[0]);
                    l_btnUpdate.ID = "l_btnUpdate";
                    l_btnUpdate.ValidationGroup = "EditVal";
                }
                e.Item.Cells[5].Controls.Add(comValDates_gd);

                if (e.Item.Cells[5].Controls[2] is Button)
                {
                    Button l_btnCancel = ((Button)e.Item.Cells[5].Controls[2]);
                    l_btnCancel.ID = "l_btnCancel";

                    Panel l_panel = new Panel();
                    l_panel.ID       = "l_panel";
                    l_panel.CssClass = "modalPopup";
                    l_panel.Style.Add("display", "none");
                    l_panel.Width = Unit.Pixel(233);

                    Label l_label = new Label();
                    l_label.Text = "Are you sure you want to continue?";

                    HtmlGenericControl l_div    = new HtmlGenericControl();
                    Button             l_ok     = new Button();
                    Button             l_cancel = new Button();
                    l_ok.ID       = "l_ok";
                    l_ok.Text     = "OK";
                    l_cancel.ID   = "l_cancel";
                    l_cancel.Text = "Cancel";
                    l_div.Controls.Add(l_ok);
                    l_div.Controls.Add(new LiteralControl("&nbsp;"));
                    l_div.Controls.Add(l_cancel);
                    l_div.Attributes.Add("align", "center");

                    l_panel.Controls.Add(l_label);
                    l_panel.Controls.Add(new LiteralControl("<br>"));
                    l_panel.Controls.Add(new LiteralControl("<br>"));
                    l_panel.Controls.Add(l_div);

                    ModalPopupExtender l_mpe = new ModalPopupExtender();
                    l_mpe.ID = "l_mpe";
                    l_mpe.TargetControlID    = l_btnCancel.ID;
                    l_mpe.PopupControlID     = l_panel.ID;
                    l_mpe.BackgroundCssClass = "modalBackground";
                    l_mpe.DropShadow         = true;
                    l_mpe.OkControlID        = l_ok.ID;
                    l_mpe.CancelControlID    = l_cancel.ID;

                    ConfirmButtonExtender l_cbe = new ConfirmButtonExtender();
                    l_cbe.TargetControlID     = l_btnCancel.ID;
                    l_cbe.ConfirmText         = "";
                    l_cbe.DisplayModalPopupID = l_mpe.ID;

                    e.Item.Cells[5].Controls.Add(l_panel);
                    e.Item.Cells[5].Controls.Add(l_cbe);
                    e.Item.Cells[5].Controls.Add(l_mpe);
                }
            }
        }
Example #11
0
    protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        //Putting calendars, DropDowns, Validation etc.

        GridView gv         = ((GridView)(sender));
        int      gridviewno = Convert.ToInt32(gv.ID.Substring(8));

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //1
            e.Row.CssClass = "row";

            for (int cell_no = 2; cell_no < e.Row.Cells.Count; cell_no++)
            {
                //Important(get tb1, tb2 etc. TextBox's ID in the aspx pages are well named, so it can be found when required )
                TextBox tb = (TextBox)e.Row.Cells[cell_no].FindControl("tb" + ((no_samples_intab * (gridviewno - 1)) + (cell_no - 1)).ToString());
                RequiredFieldValidator rfv = (RequiredFieldValidator)e.Row.Cells[cell_no].FindControl("RequiredFieldValidator" + ((no_samples_intab * (gridviewno - 1)) + (cell_no - 1)).ToString());
                rfv.Enabled = true;
                int propertyid = Convert.ToInt32(e.Row.Cells[0].Text);
                if (!other.getIsMandatoryPropertyByTypeRequest(rtype, propertyid))
                {
                    rfv.Enabled = false;
                }

                if (e.Row.RowIndex == 4 || e.Row.RowIndex == 9)
                {
                    //2 Add Calendar Extender
                    AjaxControlToolkit.CalendarExtender aj_ce = new AjaxControlToolkit.CalendarExtender();
                    aj_ce.PopupPosition   = AjaxControlToolkit.CalendarPosition.Right;
                    aj_ce.TargetControlID = tb.ID;
                    aj_ce.Format          = "dd/MM/yyyy";
                    e.Row.Cells[cell_no].Controls.Add(aj_ce);

                    if (e.Row.RowIndex == 4)
                    {
                        //Not allow future date
                        RangeValidator rv = new RangeValidator();
                        rv.ForeColor         = System.Drawing.Color.Red;
                        rv.Type              = ValidationDataType.Date;
                        rv.ErrorMessage      = "Should not be future date.";
                        rv.ValidationGroup   = "submit";
                        rv.Display           = ValidatorDisplay.Dynamic;
                        rv.ControlToValidate = tb.ID;
                        rv.MinimumValue      = DateTime.MinValue.ToString("dd/MM/yyyy");
                        rv.MaximumValue      = DateTime.Today.ToString("dd/MM/yyyy");
                        e.Row.Cells[cell_no].Controls.Add(rv);
                    }

                    if (e.Row.RowIndex == 9)
                    {
                        //Stability Date must be greater or equal to Mkg. Date
                        TextBox tb_mkg = (TextBox)gv.Rows[4].Cells[cell_no].FindControl("tb" + ((no_samples_intab * (gridviewno - 1)) + (cell_no - 1)).ToString());
                        tb.Attributes.Add("onchange", "validate_StabilityDate('" + tb_mkg.ClientID + "','" + tb.ClientID + "');");
                    }

                    //Add Compare Validator
                    CompareValidator cv = new CompareValidator();
                    cv.ForeColor         = System.Drawing.Color.Red;
                    cv.Type              = ValidationDataType.Date;
                    cv.ErrorMessage      = " Invalid Date.";
                    cv.ValidationGroup   = "submit";
                    cv.Operator          = ValidationCompareOperator.DataTypeCheck;
                    cv.Display           = ValidatorDisplay.Dynamic;
                    cv.ControlToValidate = tb.ID;
                    e.Row.Cells[cell_no].Controls.Add(cv);
                }

                if (e.Row.RowIndex == 6 || e.Row.RowIndex == 7)
                {
                    RegularExpressionValidator rx_val = new RegularExpressionValidator();
                    rx_val.ForeColor            = System.Drawing.Color.Red;
                    rx_val.ErrorMessage         = "Only Numbers";
                    rx_val.ValidationGroup      = "submit";
                    rx_val.Display              = ValidatorDisplay.Dynamic;
                    rx_val.ControlToValidate    = tb.ID;
                    rx_val.ValidationExpression = @"\d+\.{0,1}\d*";
                    e.Row.Cells[cell_no].Controls.Add(rx_val);
                }

                if (e.Row.RowIndex == 11)
                {
                    //3 Remove Textbox where dropdowns should be placed
                    tb.Attributes["style"] = "display:none";

                    //Add Dropdown for storage conditions
                    DropDownList ddl = new DropDownList();
                    ddl.ID = "ddl" + gridviewno.ToString() + (e.Row.RowIndex + 1).ToString() + (cell_no - 1).ToString();
                    AddItems_ddl(ddl);

                    e.Row.Cells[cell_no].Controls.Add(ddl);
                }
            }
        }
    }
Example #12
0
        protected override void OnLoad(EventArgs e)
        {
            bool isComparison = !string.IsNullOrEmpty(_comparisonControlID);

            if (string.IsNullOrEmpty(_targetControlID))
            {
                throw new ApplicationException("Required parameter TargetControlID not specified.");
            }

            if (string.IsNullOrEmpty(_fieldName))
            {
                throw new ApplicationException("Required parameter FieldName not specified.");
            }

            if (_required || isComparison)
            {
                RequiredFieldValidator rfv = new RequiredFieldValidator();

                rfv.ID = this.ID + "RFV";
                rfv.ControlToValidate = _targetControlID;
                rfv.Display           = ValidatorDisplay.None;
                rfv.ErrorMessage      = "<b>Required Field</b><br/>" + _fieldName + " is a required field.";
                rfv.ValidationGroup   = _validationGroup;

                this.Controls.Add(rfv);
                this.Controls.Add(GetExtender(rfv));
            }

            if (isComparison)
            {
                CompareValidator cv = new CompareValidator();

                cv.ID = this.ID + "CV";
                cv.ControlToValidate  = _targetControlID;
                cv.ControlToCompare   = _comparisonControlID;
                cv.Display            = ValidatorDisplay.None;
                cv.ErrorMessage       = "<b>Field Mismatch</b><br/>The " + _fieldName + " fields do not match.";
                cv.EnableClientScript = true;
                cv.ValidationGroup    = _validationGroup;

                this.Controls.Add(cv);
                this.Controls.Add(GetExtender(cv));
            }
            else
            {
                if (!string.IsNullOrEmpty(_mask) && string.IsNullOrEmpty(_validationRegex) && !_knownValidationRegex.HasValue)
                {
                    throw new ApplicationException("When the Mask parameter is set, the ValidationRegex or KnownValidationRegex must be set as well.");
                }

                if (!string.IsNullOrEmpty(_mask))
                {
                    MaskedEditExtender mex = new MaskedEditExtender();

                    mex.ID = this.ID + "MEX";
                    mex.TargetControlID      = _targetControlID;
                    mex.Mask                 = _mask;
                    mex.ClearMaskOnLostFocus = false;
                    mex.AutoComplete         = false;
                    mex.PromptCharacter      = "_";

                    this.Controls.Add(mex);
                }

                if (_knownValidationRegex.HasValue || !string.IsNullOrEmpty(_validationRegex))
                {
                    RegularExpressionValidator rev = new RegularExpressionValidator();

                    rev.ID = this.ID + "REV";
                    rev.ControlToValidate  = _targetControlID;
                    rev.Display            = ValidatorDisplay.None;
                    rev.ErrorMessage       = GetInvalidFieldDescription();
                    rev.EnableClientScript = true;
                    rev.ValidationGroup    = _validationGroup;

                    if (_knownValidationRegex.HasValue)
                    {
                        rev.ValidationExpression = RegexUtil.GetRegexStringForJavaScript(_knownValidationRegex.Value);
                    }
                    else
                    {
                        rev.ValidationExpression = _validationRegex;
                    }

                    this.Controls.Add(rev);
                    this.Controls.Add(GetExtender(rev));
                }
            }

            if (!string.IsNullOrEmpty(_clientValidationFunction))
            {
                CustomValidator cuv = new CustomValidator();

                cuv.ID = this.ID + "CUV";
                cuv.ControlToValidate        = _targetControlID;
                cuv.ClientValidationFunction = _clientValidationFunction;
                cuv.Display            = ValidatorDisplay.None;
                cuv.ErrorMessage       = GetInvalidFieldDescription();
                cuv.EnableClientScript = true;
                cuv.ValidationGroup    = _validationGroup;

                this.Controls.Add(cuv);
                this.Controls.Add(GetExtender(cuv));
            }

            base.OnLoad(e);
        }
Example #13
0
        protected override void OnInit(EventArgs e)
        {
            fieldDropdown = new DataField(DataFieldType.DropdownList);
            plhControls.Controls.Add(fieldDropdown);
            fieldDropdown.ID            = "Drop1";
            fieldDropdown.ValueChanged += new EventHandler(fieldDropdown_ValueChanged);

            if (!IsPostBack)
            {
                fieldDropdown.Label = "Drop1";
                ListItemCollection lst = new ListItemCollection();
                lst.Add(new ListItem("texto", "valor"));
                lst.Add(new ListItem("texto", "valor"));
                lst.Add(new ListItem("texto", "valor"));
                fieldDropdown.DataSource     = lst;
                fieldDropdown.AutoPostBack   = true;
                fieldDropdown.DataTextField  = "Text";
                fieldDropdown.DataValueField = "Value";
                fieldDropdown.DataBind();
                fieldDropdown.Value = "Leo3";
            }

            fieldDropdown2 = new DataField(DataFieldType.DropdownList);
            plhControls.Controls.Add(fieldDropdown2);
            fieldDropdown2.ID = "Drop2";

            if (!IsPostBack)
            {
                fieldDropdown2.Label      = "Drop2";
                fieldDropdown2.IsRequired = true;
                ArrayList lst = new ArrayList();
                lst.Add("Vera1");
                lst.Add("Vera2");
                lst.Add("Vera3");
                fieldDropdown2.DataSource = lst;
                fieldDropdown2.DataBind();
            }

            fieldRadiobuttonList = new DataField(DataFieldType.RadioButtonList);
            plhControls.Controls.Add(fieldRadiobuttonList);
            fieldRadiobuttonList.ID = "Rad1";

            if (!IsPostBack)
            {
                fieldRadiobuttonList.Label      = "Rad1";
                fieldRadiobuttonList.IsRequired = true;
                ArrayList lst = new ArrayList();
                lst.Add("Vera1");
                lst.Add("Vera2");
                lst.Add("Vera3");
                fieldRadiobuttonList.DataSource = lst;
                fieldRadiobuttonList.DataBind();
            }

            fieldCheckBoxList = new DataField(DataFieldType.CheckBoxList);
            plhControls.Controls.Add(fieldCheckBoxList);
            fieldCheckBoxList.ID = "Check1";

            if (!IsPostBack)
            {
                fieldCheckBoxList.Label      = "Check1";
                fieldCheckBoxList.IsRequired = true;
                ArrayList lst = new ArrayList();
                lst.Add("Vera1");
                lst.Add("Vera2");
                lst.Add("Vera3");
                fieldCheckBoxList.DataSource = lst;
                fieldCheckBoxList.DataBind();
            }

            fieldLabel = new DataField(DataFieldType.Label);
            plhControls.Controls.Add(fieldLabel);
            fieldLabel.ID = "Label1";

            if (!IsPostBack)
            {
                fieldLabel.Label = "Label1";
                fieldLabel.Value = "This is the label value";
            }

            fieldLink = new DataField(DataFieldType.HyperLink);
            plhControls.Controls.Add(fieldLink);

            fieldLink.Label = "Link1";
            fieldLink.Text  = "This is the link text";
            fieldLink.Value = "http://www.google.com";

            fieldCheckBox = new DataField(DataFieldType.CheckBox);
            plhControls.Controls.Add(fieldCheckBox);
            fieldCheckBox.Label = "CheckBox1";
            fieldCheckBox.Value = true;

            fieldDate = new DataField(DataFieldType.Date);
            plhControls.Controls.Add(fieldDate);
            fieldDate.Label = "Date1";
            fieldDate.Value = DateTime.Today;

            fieldRange = new DataField(DataFieldType.DateRange);
            plhControls.Controls.Add(fieldRange);
            fieldRange.Label     = "DateRange1";
            fieldRange.ValueFrom = DateTime.Today;
            fieldRange.ValueTo   = DateTime.Today.AddDays(123);

            fieldInteger = new DataField(DataFieldType.Number);
            plhControls.Controls.Add(fieldInteger);
            fieldInteger.Label = "Integer1";
            if (!IsPostBack)
            {
                fieldInteger.Value = 20;
            }

            CompareValidator cmp = new CompareValidator();

            cmp.Operator        = ValidationCompareOperator.Equal;
            cmp.ValueToCompare  = "20";
            cmp.ErrorMessage    = "LEO";
            cmp.Text            = "LEO";
            cmp.ValidationGroup = "form";
            fieldInteger.AddValidator(cmp);

            CustomValidator cval = new CustomValidator();

            cval.ID              = "AAAAAAA";
            cval.ServerValidate += new ServerValidateEventHandler(cval_ServerValidate);
            cval.ErrorMessage    = "LEO";
            cval.Text            = "LEO";
            cval.ValidationGroup = "form";
            fieldInteger.AddValidator(cval);

            //CompareValidator cmp = new CompareValidator();
            //cmp.Operator = ValidationCompareOperator.Equal;
            //cmp.ValueToCompare = "20";
            //cmp.ErrorMessage = "LEO";
            //cmp.Text = "LEO";
            //fieldInteger.AddValidator(cmp);

            fieldCurrency = new DataField(DataFieldType.Number);
            plhControls.Controls.Add(fieldCurrency);

            fieldCurrency.NumberType     = DataNumberType.Currency;
            fieldCurrency.CurrencySymbol = "$";
            fieldCurrency.Label          = "Decimal1";
            fieldCurrency.IsRequired     = true;
            fieldCurrency.ReadOnly       = true;
            fieldCurrency.Value          = 19.33;

            fieldEmail = new DataField(DataFieldType.Email);
            plhControls.Controls.Add(fieldEmail);
            fieldEmail.Label   = "Text1";
            fieldEmail.Enabled = false;
            fieldEmail.Value   = "*****@*****.**";

            fieldText = new DataField(DataFieldType.Text);
            plhControls.Controls.Add(fieldText);

            fieldText.ID = "Text1";
            if (!IsPostBack)
            {
                fieldText.Label = "Text1";
                fieldText.Value = "This is a common text field.";
            }

            fieldDropdown3 = new DataField(DataFieldType.DropdownList);
            plhControls.Controls.Add(fieldDropdown3);
            fieldDropdown3.ID            = "Drop2M";
            fieldDropdown3.ValueChanged += new EventHandler(fieldDropdown_ValueChanged);

            if (!IsPostBack)
            {
                fieldDropdown3.Label      = "Drop2M";
                fieldDropdown3.IsRequired = true;
                ListItemCollection lst = new ListItemCollection();
                lst.Add(new ListItem("texto", "valor"));
                lst.Add(new ListItem("texto", "valor"));
                lst.Add(new ListItem("texto", "valor"));
                fieldDropdown3.DataSource     = lst;
                fieldDropdown3.AutoPostBack   = true;
                fieldDropdown3.DataTextField  = "Text";
                fieldDropdown3.DataValueField = "Value";
                fieldDropdown3.DataBind();
                //fieldDropdown.Value = "Leo3";
            }

            fieldLongText = new DataField(DataFieldType.LongText);
            plhControls.Controls.Add(fieldLongText);
            fieldLongText.Label = "Text1";
            fieldLongText.Value = "This is a common text area field.";

            fieldHtml = new DataField(DataFieldType.HtmlEditor);
            plhControls.Controls.Add(fieldHtml);
            fieldHtml.Label = "Text1";
            fieldHtml.Value = "This is a HTML <b>enabled</b> field common text area field. Requeries tinyMce installed.";

            base.OnInit(e);
        }
        private void PopulateLabels()
        {
            Title = SiteUtils.FormatPageTitle(siteSettings, Resource.ChangePasswordLabel);

            Button changePasswordButton = (Button)ChangePassword1.ChangePasswordTemplateContainer.FindControl("ChangePasswordPushButton");
            Button cancelButton         = (Button)ChangePassword1.ChangePasswordTemplateContainer.FindControl("CancelPushButton");

            if (changePasswordButton != null)
            {
                changePasswordButton.Text = Resource.ChangePasswordButton;
                SiteUtils.SetButtonAccessKey(changePasswordButton, AccessKeys.ChangePasswordButtonAccessKey);
            }
            else
            {
                log.Debug("couldn't find changepasswordbutton so couldn't set label");
            }

            if (cancelButton != null)
            {
                cancelButton.Text = Resource.ChangePasswordCancelButton;
                SiteUtils.SetButtonAccessKey(cancelButton, AccessKeys.ChangePasswordCancelButtonAccessKey);
            }
            else
            {
                log.Debug("couldn't find cancelbutton so couldn't set label");
            }


            this.ChangePassword1.CancelDestinationPageUrl
                = SiteUtils.GetNavigationSiteRoot() + "/Secure/UserProfile.aspx";

            this.ChangePassword1.ChangePasswordFailureText
                = Resource.ChangePasswordFailureText;

            CompareValidator newPasswordCompare
                = (CompareValidator)ChangePassword1.ChangePasswordTemplateContainer.FindControl("NewPasswordCompare");

            if (newPasswordCompare != null)
            {
                newPasswordCompare.ErrorMessage = Resource.ChangePasswordMustMatchConfirmMessage;
            }

            RequiredFieldValidator confirmNewPasswordRequired
                = (RequiredFieldValidator)ChangePassword1.ChangePasswordTemplateContainer.FindControl("ConfirmNewPasswordRequired");

            if (confirmNewPasswordRequired != null)
            {
                confirmNewPasswordRequired.ErrorMessage = Resource.ChangePasswordConfirmPasswordRequiredMessage;
            }

            this.ChangePassword1.ContinueDestinationPageUrl
                = SiteUtils.GetNavigationSiteRoot();

            RequiredFieldValidator newPasswordRequired
                = (RequiredFieldValidator)ChangePassword1.ChangePasswordTemplateContainer.FindControl("NewPasswordRequired");

            if (newPasswordRequired != null)
            {
                newPasswordRequired.ErrorMessage = Resource.ChangePasswordNewPasswordRequired;
            }


            RequiredFieldValidator currentPasswordRequired
                = (RequiredFieldValidator)ChangePassword1.ChangePasswordTemplateContainer.FindControl("CurrentPasswordRequired");

            if (currentPasswordRequired != null)
            {
                currentPasswordRequired.ErrorMessage = Resource.ChangePasswordCurrentPasswordRequiredWarning;
            }

            RegularExpressionValidator newPasswordRegex
                = (RegularExpressionValidator)ChangePassword1.ChangePasswordTemplateContainer.FindControl("NewPasswordRegex");

            if (newPasswordRegex != null)
            {
                newPasswordRegex.ErrorMessage = Resource.ChangePasswordPasswordRegexFailureMessage;
                if (siteSettings.PasswordRegexWarning.Length > 0)
                {
                    newPasswordRegex.ErrorMessage = siteSettings.PasswordRegexWarning;
                }

                newPasswordRegex.ValidationExpression = Membership.PasswordStrengthRegularExpression;

                if (Membership.PasswordStrengthRegularExpression.Length == 0)
                {
                    newPasswordRegex.Visible         = false;
                    newPasswordRegex.ValidationGroup = "None";
                }
            }

            CustomValidator newPasswordRulesValidator
                = (CustomValidator)ChangePassword1.ChangePasswordTemplateContainer.FindControl("NewPasswordRulesValidator");

            if (newPasswordRulesValidator != null)
            {
                newPasswordRulesValidator.ServerValidate += new ServerValidateEventHandler(NewPasswordRulesValidator_ServerValidate);
            }

            this.ChangePassword1.SuccessTitleText = String.Empty;
            this.ChangePassword1.SuccessText      = Resource.ChangePasswordSuccessText;

            if (siteSettings.ShowPasswordStrengthOnRegistration)
            {
                PasswordStrength passwordStrengthChecker = (PasswordStrength)ChangePassword1.ChangePasswordTemplateContainer.FindControl("passwordStrengthChecker");
                if (passwordStrengthChecker != null)
                {
                    passwordStrengthChecker.Enabled = true;
                    passwordStrengthChecker.RequiresUpperAndLowerCaseCharacters = true;
                    passwordStrengthChecker.MinimumLowerCaseCharacters          = WebConfigSettings.PasswordStrengthMinimumLowerCaseCharacters;
                    passwordStrengthChecker.MinimumUpperCaseCharacters          = WebConfigSettings.PasswordStrengthMinimumUpperCaseCharacters;
                    passwordStrengthChecker.MinimumSymbolCharacters             = siteSettings.MinRequiredNonAlphanumericCharacters;
                    passwordStrengthChecker.PreferredPasswordLength             = siteSettings.MinRequiredPasswordLength;

                    passwordStrengthChecker.PrefixText = Resource.PasswordStrengthPrefix;
                    passwordStrengthChecker.TextStrengthDescriptions = Resource.PasswordStrengthDescriptions;
                    passwordStrengthChecker.CalculationWeightings    = WebConfigSettings.PasswordStrengthCalculationWeightings;

                    try
                    {
                        passwordStrengthChecker.StrengthIndicatorType = (StrengthIndicatorTypes)Enum.Parse(typeof(StrengthIndicatorTypes), WebConfigSettings.PasswordStrengthIndicatorType, true);
                    }
                    catch (ArgumentException)
                    {
                        passwordStrengthChecker.StrengthIndicatorType = StrengthIndicatorTypes.Text;
                    }
                    catch (OverflowException)
                    {
                        passwordStrengthChecker.StrengthIndicatorType = StrengthIndicatorTypes.Text;
                    }

                    try
                    {
                        passwordStrengthChecker.DisplayPosition = (DisplayPosition)Enum.Parse(typeof(DisplayPosition), WebConfigSettings.PasswordStrengthDisplayPosition, true);
                    }
                    catch (ArgumentException)
                    {
                        passwordStrengthChecker.DisplayPosition = DisplayPosition.RightSide;
                    }
                    catch (OverflowException)
                    {
                        passwordStrengthChecker.DisplayPosition = DisplayPosition.RightSide;
                    }
                }
            }

            AddClassToBody("changepassword");
        }
    protected void Page_Load(object sender, System.EventArgs e)
    {
        if (Session["cd_projeto"] != null)
        {
            cd_projeto = Int32.Parse(Session["cd_projeto"].ToString());
        }

        int numcells = 3;
        int j;

        TableRow HeaderRow = new TableRow();
        HeaderRow.Style["color"] = "white";
        HeaderRow.Style["font-weight"]= "bold";
        HeaderRow.Style["text-align"] = "center";
        HeaderRow.Style["background-color"] = "#5D7B9D";
        tbAnos.Rows.Add(HeaderRow);

        //-- Add header cells to the row
        TableCell HeaderCell_1 = new TableCell();
        HeaderCell_1.Text = "Ano";
        HeaderRow.Cells.Add(HeaderCell_1);

        TableCell HeaderCell_2 = new TableCell();
        HeaderCell_2.Text = "Previsto";
        HeaderRow.Cells.Add(HeaderCell_2);

        TableCell HeaderCell_3 = new TableCell();
        HeaderCell_3.Text = "Realizado";
        HeaderRow.Cells.Add(HeaderCell_3);

        t03_projeto t03 = new t03_projeto();
        t03.t03_cd_projeto = cd_projeto;
        t03.Retrieve();
        if (t03.Found)
        {
            for (j = t03.dt_inicio.Year; j <= t03.dt_fim.Year; j++)
            {
                TableRow r = new TableRow();
                r.Style["background-color"] = "#F1F5F5";
                int i;
                for (i = 0; i <= numcells - 1; i++)
                {
                    TableCell c = new TableCell();
                    TextBox UserTextBox = new TextBox();
                    CompareValidator val = new CompareValidator();
                    switch (i)
                    {
                        case 0:
                            //ANO
                            c.Controls.Add(new LiteralControl(j.ToString()));
                            r.Cells.Add(c);
                            break;
                        case 1:
                            //PREVISTO
                            UserTextBox.ID = "txtPrev" + j.ToString();
                            UserTextBox.Columns = 18;
                            UserTextBox.MaxLength = 18;
                            UserTextBox.EnableViewState = true;
                            UserTextBox.Text = "0";

                            val.ID = "val" + j.ToString();
                            val.ControlToValidate = UserTextBox.ID;
                            val.ErrorMessage = "<br>*formato inválido";
                            val.Display = ValidatorDisplay.Dynamic;
                            val.Operator = ValidationCompareOperator.DataTypeCheck;
                            val.Type = ValidationDataType.Currency;
                            c.Controls.Add(UserTextBox);
                            c.Controls.Add(val);
                            r.Cells.Add(c);
                            break;
                        case 2:
                            //REALIZADO

                            UserTextBox.ID = "txtReal" + j.ToString();
                            UserTextBox.Columns = 18;
                            UserTextBox.MaxLength = 18;
                            UserTextBox.EnableViewState = true;
                            UserTextBox.Text = "0";

                            val.ID = "valr" + j.ToString();
                            val.ControlToValidate = UserTextBox.ID;
                            val.ErrorMessage = "<br>*formato inválido";
                            val.Display = ValidatorDisplay.Dynamic;
                            val.Operator = ValidationCompareOperator.DataTypeCheck;
                            val.Type = ValidationDataType.Currency;

                            c.Controls.Add(UserTextBox);
                            c.Controls.Add(val);
                            r.Cells.Add(c);
                            break;
                    }

                }
                tbAnos.Rows.Add(r);
            }
        }
    }
        protected void grdRecords_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                // Verificar que si el lote es nulo o vacio
                string strLote = ((DataRowView)e.Row.DataItem).DataView.Table.Rows[e.Row.RowIndex]["IND_LOTE"].ToString();
                string strItem = ((DataRowView)e.Row.DataItem).DataView.Table.Rows[e.Row.RowIndex]["ARTICULO"].ToString();
                if (string.IsNullOrEmpty(strLote))
                {
                    ((DropDownList)e.Row.Cells[5].FindControl("toLot")).Enabled = false;
                    // ((TextBox)e.Row.Cells[5].FindControl("toLot")).Enabled = false;
                }
                else
                {
                    DataRow drv  = ((DataRowView)e.Row.DataItem).Row;
                    var     fila = drv.ItemArray.ToArray();

                    var serializador    = new JavaScriptSerializer();
                    var FilaSerializada = serializador.Serialize(fila);

                    //((RangeValidator)e.Row.Cells[4].FindControl("validateQuantity")).MinimumValue = "0";
                    TextBox toReturn = (TextBox)e.Row.Cells[4].FindControl("toReturn");
//                    TextBox toLot = (TextBox)e.Row.Cells[5].FindControl("toLot");

                    strLote = ((DataRowView)e.Row.DataItem).DataView.Table.Rows[e.Row.RowIndex]["IND_LOTE"].ToString();

                    obj      = new Ent_tticol090();
                    obj.tpdn = txtWorkOrderFrom.Text.Trim().ToUpperInvariant();
                    obj.item = strItem;
                    DataTable lotesItem = idal.lineClearance_verificaLote_Param(ref obj, ref strError);

                    if (toReturn != null)
                    {
                        string           dataCant = ((DataRowView)e.Row.DataItem).DataView.Table.Rows[e.Row.RowIndex]["ACT_CANT"].ToString();
                        CompareValidator objVal   = (CompareValidator)e.Row.Cells[4].FindControl("validateQuantity");

                        objVal.ValueToCompare    = dataCant;
                        objVal.ControlToValidate = toReturn.ID;
                        //objVal.Enabled = true;

                        //((RangeValidator)e.Row.Cells[4].FindControl("validateQuantity")).MaximumValue = ((DataRowView)e.Row.DataItem).DataView.Table.Rows[e.Row.RowIndex]["ACT_CANT"].ToString();


                        //((TextBox)e.Row.Cells[4].FindControl("toReturn")).Attributes.Add("onblur", "if(this.value != '') " +
                        //                                                                           "{ validaInfo('" + strItem + "' , '1',this); }");
                        ((TextBox)e.Row.Cells[4].FindControl("toReturn")).Attributes.Add("onblur", "if(this.value != '') " +
                                                                                         "{ validaInfo('" + strItem + "' , '1',this); " +
                                                                                         "validateMov('" + dataCant + "',this.value, '" + objVal.ClientID + "', this);}");
                        ((TextBox)e.Row.Cells[4].FindControl("toReturn")).Attributes.Add("onfocus", "limpiar(this);");
                    }

                    if (strLote != "1")
                    {
                        ((DropDownList)e.Row.Cells[5].FindControl("toLot")).Enabled = false;
                        //((TextBox)e.Row.Cells[5].FindControl("toLot")).Enabled = false;
                    }
                    else
                    {
                        DataRow filaIni = lotesItem.NewRow();
                        filaIni[0] = "  ";
                        filaIni[1] = " - Select Lot - ";
                        lotesItem.Rows.InsertAt(filaIni, 0);

                        DropDownList lista = ((DropDownList)e.Row.Cells[5].FindControl("toLot"));
                        lista.DataSource     = lotesItem;
                        lista.DataTextField  = "DESCRIPCION";
                        lista.DataValueField = "LOTE";
                        lista.DataBind();

                        //((TextBox)e.Row.Cells[5].FindControl("toLot")).Attributes.Add("onblur", "if(this.value != ''){ validaInfo(this.value +'|" + strItem.Trim() + "', '2', this);}");
                        //((TextBox)e.Row.Cells[5].FindControl("toLot")).Attributes.Add("onfocus", "limpiar(this);");
                    }
                }
            }
        }
        private PlaceHolder DetermineConfigEditControl(string StoreName, int StoreId, AppConfig config)
        {
            PlaceHolder plhConfigValueEditor = new PlaceHolder();
            String      editorId;
            Boolean     isnew = (config == null);

            if (isnew)
            {
                //return AddParameterControl(StoreName, StoreId, config);
                config   = AppLogic.GetAppConfigRouted(this.Datasource.Name, StoreId);
                editorId = string.Format("ctrlNewConfig{0}_{1}", StoreId, this.Datasource.AppConfigID);
                plhConfigValueEditor.Controls.Add(new LiteralControl("<small style=\"color:gray;\">(Unassigned for <em>{0}</em>. Currently using default.)</small><br />".FormatWith(Store.GetStoreName(StoreId))));
            }
            else
            {
                editorId = string.Format("ctrlConfigEditor{0}", config.AppConfigID);
            }


            if (config.ValueType.EqualsIgnoreCase("integer"))
            {
                TextBox txt = new TextBox();
                txt.ID        = editorId;
                txt.Text      = config.ConfigValue;
                m_configvalue = txt.Text;

                CompareValidator compInt = new CompareValidator();
                compInt.Type              = ValidationDataType.Integer;
                compInt.Operator          = ValidationCompareOperator.DataTypeCheck;
                compInt.ControlToValidate = txt.ID;
                compInt.ErrorMessage      = AppLogic.GetString("admin.editquantitydiscounttable.EnterInteger", ThisCustomer.LocaleSetting);

                plhConfigValueEditor.Controls.Add(txt);
                plhConfigValueEditor.Controls.Add(compInt);
            }
            else if (config.ValueType.EqualsIgnoreCase("decimal") || config.ValueType.EqualsIgnoreCase("double"))
            {
                TextBox txt = new TextBox();
                txt.ID        = editorId;
                txt.Text      = config.ConfigValue;
                m_configvalue = txt.Text;

                FilteredTextBoxExtender extFilterNumeric = new FilteredTextBoxExtender();
                extFilterNumeric.ID = DB.GetNewGUID();
                extFilterNumeric.TargetControlID = editorId;
                extFilterNumeric.FilterType      = FilterTypes.Numbers | FilterTypes.Custom;
                extFilterNumeric.ValidChars      = ".";

                plhConfigValueEditor.Controls.Add(txt);
                plhConfigValueEditor.Controls.Add(extFilterNumeric);
            }
            else if (config.ValueType.EqualsIgnoreCase("boolean"))
            {
                bool isYes = Localization.ParseBoolean(config.ConfigValue);

                RadioButtonList rbYesNo = new RadioButtonList();
                rbYesNo.ID = editorId;
                rbYesNo.RepeatDirection = System.Web.UI.WebControls.RepeatDirection.Horizontal;

                ListItem optionYes = new ListItem("Yes");
                ListItem optionNo  = new ListItem("No");

                if (StoreId == 0)
                {
                    optionYes.Attributes.Add("onclick", "$(this).parents('.modal_popup_Content').find('span.defaultTrue input').each(function (index, value) {$(value).click();});");
                    optionNo.Attributes.Add("onclick", "$(this).parents('.modal_popup_Content').find('span.defaultFalse input').each(function (index, value) {$(value).click();});");
                }
                else if (isnew)
                {
                    optionYes.Attributes.Add("class", "defaultTrue");
                    optionNo.Attributes.Add("class", "defaultFalse");
                }

                optionYes.Selected = isYes;
                optionNo.Selected  = !isYes;

                rbYesNo.Items.Add(optionYes);
                rbYesNo.Items.Add(optionNo);

                m_configvalue = optionYes.Selected.ToString().ToLowerInvariant();

                plhConfigValueEditor.Controls.Add(rbYesNo);
            }
            else if (config.ValueType.EqualsIgnoreCase("enum"))
            {
                DropDownList cboValues = new DropDownList();
                cboValues.ID = editorId;
                foreach (string value in config.AllowableValues)
                {
                    cboValues.Items.Add(value);
                }
                cboValues.SelectedValue = config.ConfigValue;

                m_configvalue = cboValues.SelectedValue;

                plhConfigValueEditor.Controls.Add(cboValues);
            }
            else if (config.ValueType.EqualsIgnoreCase("invoke"))
            {
                DropDownList cboValues = new DropDownList();
                cboValues.ID = editorId;

                bool   invocationSuccessful = false;
                string errorMessage         = string.Empty;

                try
                {
                    if (config.AllowableValues.Count == 3)
                    {
                        // format should be
                        // {FullyQualifiedName},MethodName
                        // Fully qualified name format is Namespace.TypeName,AssemblyName
                        string typeName     = config.AllowableValues[0];
                        string assemblyName = config.AllowableValues[1];
                        string methodName   = config.AllowableValues[2];

                        string     fqName = typeName + "," + assemblyName;
                        Type       t      = Type.GetType(fqName);
                        object     o      = Activator.CreateInstance(t);
                        MethodInfo method = o.GetType().GetMethod(methodName, BindingFlags.Public | BindingFlags.Static);
                        object     result = method.Invoke(o, new object[] { });

                        if (result is IEnumerable)
                        {
                            cboValues.DataSource = result;
                            cboValues.DataBind();

                            invocationSuccessful = true;

                            // now try to find which one is matching, case-insensitive
                            foreach (ListItem item in cboValues.Items)
                            {
                                item.Selected = item.Text.EqualsIgnoreCase(config.ConfigValue);
                            }
                        }
                        else
                        {
                            errorMessage         = "Invocation method must return IEnumerable";
                            invocationSuccessful = false;
                        }
                    }
                    else
                    {
                        errorMessage         = "Invalid invocation value";
                        invocationSuccessful = false;
                    }
                }
                catch (Exception ex)
                {
                    errorMessage         = ex.Message;
                    invocationSuccessful = false;
                }

                if (invocationSuccessful == false)
                {
                    cboValues.Items.Add(errorMessage);
                }

                m_configvalue = cboValues.SelectedValue;

                plhConfigValueEditor.Controls.Add(cboValues);
            }
            else if (config.ValueType.EqualsIgnoreCase("multiselect"))
            {
                CheckBoxList chkValues = new CheckBoxList();
                chkValues.ID = editorId;

                Func <string, bool> isIncluded = (optionValue) =>
                {
                    return(config.ConfigValue.Split(',').Any(val => val.Trim().EqualsIgnoreCase(optionValue)));
                };

                foreach (string optionValue in config.AllowableValues)
                {
                    ListItem option = new ListItem(optionValue, optionValue);
                    option.Selected = isIncluded(optionValue);
                    chkValues.Items.Add(option);
                }

                List <string> selectedValues = new List <string>();
                foreach (ListItem option in chkValues.Items)
                {
                    if (option.Selected)
                    {
                        selectedValues.Add(option.Value);
                    }
                }

                // format the selected values into a comma delimited string
                m_configvalue = selectedValues.ToCommaDelimitedString();

                plhConfigValueEditor.Controls.Add(chkValues);
            }
            else
            {
                // determine length for proper control to use
                string configValue = config.ConfigValue;

                TextBox txt = new TextBox();
                txt.ID   = editorId;
                txt.Text = configValue;

                if (configValue.Length >= MAX_COLUMN_LENGTH)
                {
                    // use textArea
                    txt.TextMode = TextBoxMode.MultiLine;
                    txt.Rows     = 4; // make it 4 rows by default
                }

                txt.Columns = DetermineProperTextColumnLength(configValue);

                m_configvalue = txt.Text;

                plhConfigValueEditor.Controls.Add(txt);
            }

            return(plhConfigValueEditor);
        }
Example #18
0
 public override bool IsValid(object value)
 {
     return(CompareValidator.IsValidRelativeToZero(ComparisonOperator.LessThanOrEqualTo, value));
 }
        public void Validate_ReturnValue_AreEqual(string value, string comparisonValue, bool isValid)
        {
            CompareValidator validator = new CompareValidator("", value, "", comparisonValue);

            Assert.AreEqual(validator.Validate(), isValid);
        }
Example #20
0
        /// <summary>
        /// Init the components of the panel through the special pageid
        /// </summary>
        private void InitComponents()
        {
            HtmlTable T_Content = new HtmlTable();

            T_Content.CellPadding = 0;
            T_Content.CellSpacing = 0;
            T_Content.Width       = "100%";
            T_Content.Border      = 0;
            T_Content.ID          = "T_Content_" + ID;
            this.Controls.Add(T_Content);


            UD_DetailViewBLL _DetailViewBll = new UD_DetailViewBLL(DetailViewCode, true);

            IList <UD_Panel> _panellist           = _DetailViewBll.GetDetailPanels();
            Hashtable        _htFieldControlsInfo = new Hashtable();

            foreach (UD_Panel _panelmodel in _panellist)
            {
                HtmlTableRow tr_panel = new HtmlTableRow();//Create one TableRow for a panel
                tr_panel.ID = _panelmodel.Code;
                if (_panelmodel.Enable.ToUpper() == "N")
                {
                    tr_panel.Visible = false;
                }
                HtmlTableCell tc_panel     = new HtmlTableCell();
                string        _tablestytle = _panelmodel.TableStyle;
                string[]      _tablestyles = _panelmodel.TableStyle.Split(new char[] { ',' });

                if (_tablestyles.Length < 3)
                {
                    _tablestyles = ("tabForm,dataLabel,dataField").Split(new char[] { ',' });
                }

                #region The title of the panel
                if (_panelmodel.Name != "")
                {
                    HtmlTable tb_panel_title = new HtmlTable();
                    tb_panel_title.CellPadding         = 0;
                    tb_panel_title.CellSpacing         = 0;
                    tb_panel_title.Width               = "100%";
                    tb_panel_title.Height              = "28px";
                    tb_panel_title.Border              = 0;
                    tb_panel_title.Attributes["class"] = "h3Row";
                    HtmlTableRow  tr_panel_title = new HtmlTableRow();
                    HtmlTableCell tc_panel_title = new HtmlTableCell();
                    tc_panel_title.InnerHtml = "<h3>" + _panelmodel.Name + "</h3>";
                    tr_panel_title.Cells.Add(tc_panel_title);
                    tb_panel_title.Rows.Add(tr_panel_title);
                    tc_panel.Controls.Add(tb_panel_title);
                }
                #endregion

                #region The content of the panel
                IList <UD_Panel_ModelFields> fields = new UD_PanelBLL(_panelmodel.ID, true).GetModelFields();

                int FieldCount = _panelmodel.FieldCount;

                HtmlTable tb_panel_content = new HtmlTable();
                tb_panel_content.Width = "100%";
                tb_panel_content.Attributes["class"] = _tablestyles[0];
                int i = 0;
                foreach (UD_Panel_ModelFields _panel_modelfields in fields)
                {
                    if (_panel_modelfields.Visible == "N")
                    {
                        continue;
                    }

                    UD_ModelFields _modelfieldsmodel = new UD_ModelFieldsBLL(_panel_modelfields.FieldID, true).Model;
                    UD_TableList   _tablemodel       = new UD_TableListBLL(_modelfieldsmodel.TableID, true).Model;

                    #region 判断该控件是否已存在
                    if (_htFieldControlsInfo.Contains(_tablemodel.ModelClassName + "_" + _modelfieldsmodel.FieldName))
                    {
                        continue;
                    }
                    #endregion

                    #region 判断是否要增加新行
                    HtmlTableRow tr_panel_detail;
                    if (i >= FieldCount || i == 0)
                    {
                        tr_panel_detail = new HtmlTableRow();
                        tb_panel_content.Rows.Add(tr_panel_detail);
                        i = 0;
                    }
                    else
                    {
                        tr_panel_detail = tb_panel_content.Rows[tb_panel_content.Rows.Count - 1];
                    }
                    #endregion

                    #region 增加Label Cell
                    HtmlTableCell tc_displayname = new HtmlTableCell();
                    tc_displayname.Attributes["Class"] = _tablestyles[1];
                    tc_displayname.InnerText           = string.IsNullOrEmpty(_panel_modelfields.LabelText) ?
                                                         _modelfieldsmodel.DisplayName : _panel_modelfields.LabelText;
                    if (tc_displayname.InnerText.Length <= 6)
                    {
                        tc_displayname.Attributes["Style"] = "width: 80px; height: 18px;";
                    }
                    else
                    {
                        tc_displayname.Attributes["Style"] = "width: 100px; height: 18px;";
                    }
                    tc_displayname.Attributes["nowrap"] = "nowrap";
                    tr_panel_detail.Cells.Add(tc_displayname);
                    #endregion

                    #region 增加Field Cell
                    HtmlTableCell tc_control = new HtmlTableCell();
                    tc_control.Attributes["Class"] = _tablestyles[2];
                    if (_panel_modelfields.ColSpan > 0)
                    {
                        if (i + _panel_modelfields.ColSpan <= FieldCount)
                        {
                            tc_control.ColSpan = 2 * _panel_modelfields.ColSpan - 1;
                            i = i + _panel_modelfields.ColSpan;
                        }
                        else
                        {
                            tc_control.ColSpan = 2 * (FieldCount - i) - 1;
                            i = 0;
                        }
                    }
                    else
                    {
                        i++;
                    }

                    WebControl control = null;

                    int    RelationType       = _modelfieldsmodel.RelationType;
                    string RelationTableName  = _modelfieldsmodel.RelationTableName;
                    string RelationValueField = _modelfieldsmodel.RelationValueField;
                    string RelationTextField  = _modelfieldsmodel.RelationTextField;

                    #region 根据控件类型生成相应的控件
                    switch (_panel_modelfields.ControlType)
                    {
                    case 1:    //Label
                        control = new Label();
                        break;

                    case 2:    //TextBox
                        control = new TextBox();
                        if (_modelfieldsmodel.DataType == 4)
                        {
                            control.Attributes["onfocus"] = "WdatePicker();";
                        }
                        break;

                    case 3:                    //DropDownList
                        control = new DropDownList();
                        if (RelationType == 1) //Relation to the dictionary
                        {
                            ((DropDownList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true);
                        }
                        else if (RelationType == 2)    //Relation to the model table
                        {
                            ((DropDownList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField);
                        }
                        else
                        {
                            break;
                        }

                        ((DropDownList)control).DataTextField  = "Value";
                        ((DropDownList)control).DataValueField = "Key";
                        ((DropDownList)control).DataBind();
                        if (_modelfieldsmodel.DataType != 5)
                        {
                            ((DropDownList)control).Items.Insert(0, new ListItem("请选择...", "0"));
                        }
                        else
                        {
                            ((DropDownList)control).Items.Insert(0, new ListItem("请选择...", Guid.Empty.ToString()));
                        }
                        break;

                    case 4:                    //RadioButtonList
                        control = new RadioButtonList();
                        if (RelationType == 1) //Relation to the dictionary
                        {
                            ((RadioButtonList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true);
                        }
                        else if (RelationType == 2)    //Relation to the model table
                        {
                            ((RadioButtonList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField);
                        }
                        else
                        {
                            break;
                        }

                        ((RadioButtonList)control).RepeatColumns   = 6;
                        ((RadioButtonList)control).RepeatDirection = RepeatDirection.Horizontal;
                        ((RadioButtonList)control).DataTextField   = "Value";
                        ((RadioButtonList)control).DataValueField  = "Key";
                        ((RadioButtonList)control).DataBind();
                        if (((RadioButtonList)control).Items.Count != 0)
                        {
                            ((RadioButtonList)control).SelectedIndex = 0;
                        }
                        break;

                    case 5:    //MutiLinesTextBox
                        control = new TextBox();
                        ((TextBox)control).TextMode = TextBoxMode.MultiLine;
                        if (_panel_modelfields.ControlHeight > 0)
                        {
                            ((TextBox)control).Height = new Unit(_panel_modelfields.ControlHeight);
                        }
                        break;

                    case 6:                    //TextBox supports search
                        control = new MCSSelectControl();
                        if (RelationType == 2) //Relation to the model table
                        {
                            control.ID = _tablemodel.ModelClassName + "_" + _modelfieldsmodel.FieldName;

                            if (_panel_modelfields.SearchPageURL != "")
                            {
                                ((MCSSelectControl)control).PageUrl = _panel_modelfields.SearchPageURL;
                            }
                            else if (_modelfieldsmodel.SearchPageURL != "")
                            {
                                ((MCSSelectControl)control).PageUrl = _modelfieldsmodel.SearchPageURL;
                            }
                        }
                        break;

                    case 7:    //MCSTreeControl

                        control = new MCSTreeControl();


                        if (RelationType == 2)    //Relation to the model table
                        {
                            control.ID = _tablemodel.ModelClassName + "_" + _modelfieldsmodel.FieldName;

                            if (_modelfieldsmodel.RelationTableName == "MCS_SYS.dbo.Addr_OrganizeCity")
                            {
                                #region 如果为管理片区字段,则取所能管辖的片区
                                if (System.Web.HttpContext.Current.Session["AccountType"] == null ||
                                    (int)System.Web.HttpContext.Current.Session["AccountType"] == 1)
                                {
                                    //员工
                                    Org_StaffBLL staff = new Org_StaffBLL((int)System.Web.HttpContext.Current.Session["UserID"]);
                                    ((MCSTreeControl)control).DataSource       = staff.GetStaffOrganizeCity();
                                    ((MCSTreeControl)control).IDColumnName     = "ID";
                                    ((MCSTreeControl)control).NameColumnName   = "Name";
                                    ((MCSTreeControl)control).ParentColumnName = "SuperID";

                                    if (((MCSTreeControl)control).DataSource.Select("ID = 1").Length > 0 || staff.Model.OrganizeCity == 0)
                                    {
                                        ((MCSTreeControl)control).RootValue = "0";
                                        if (!Page.IsPostBack)
                                        {
                                            ((MCSTreeControl)control).SelectValue = "0";
                                        }
                                    }
                                    else
                                    {
                                        ((MCSTreeControl)control).RootValue = new Addr_OrganizeCityBLL(staff.Model.OrganizeCity).Model.SuperID.ToString();
                                        if (!Page.IsPostBack)
                                        {
                                            ((MCSTreeControl)control).SelectValue = staff.Model.OrganizeCity.ToString();
                                        }
                                    }
                                }
                                else if ((int)System.Web.HttpContext.Current.Session["AccountType"] == 2 &&
                                         System.Web.HttpContext.Current.Session["OrganizeCity"] != null)
                                {
                                    //商业客户

                                    int city = (int)System.Web.HttpContext.Current.Session["OrganizeCity"];
                                    Addr_OrganizeCityBLL citybll = new Addr_OrganizeCityBLL(city);
                                    ((MCSTreeControl)control).DataSource       = citybll.GetAllChildNodeIncludeSelf();
                                    ((MCSTreeControl)control).RootValue        = citybll.Model.SuperID.ToString();
                                    ((MCSTreeControl)control).IDColumnName     = "ID";
                                    ((MCSTreeControl)control).NameColumnName   = "Name";
                                    ((MCSTreeControl)control).ParentColumnName = "SuperID";

                                    if (!Page.IsPostBack)
                                    {
                                        ((MCSTreeControl)control).SelectValue = city.ToString();
                                    }
                                }
                                #endregion
                            }
                            else if (_modelfieldsmodel.RelationTableName == "MCS_SYS.dbo.Addr_OfficialCity")
                            {
                                ((MCSTreeControl)control).TableName        = "MCS_SYS.dbo.Addr_OfficialCity";
                                ((MCSTreeControl)control).IDColumnName     = "ID";
                                ((MCSTreeControl)control).NameColumnName   = "Name";
                                ((MCSTreeControl)control).ParentColumnName = "SuperID";
                                ((MCSTreeControl)control).RootValue        = "0";
                                if (!Page.IsPostBack)
                                {
                                    ((MCSTreeControl)control).SelectValue = "0";
                                }
                            }
                            else
                            {
                                ((MCSTreeControl)control).TableName        = RelationTableName;
                                ((MCSTreeControl)control).IDColumnName     = RelationValueField;
                                ((MCSTreeControl)control).NameColumnName   = RelationTextField;
                                ((MCSTreeControl)control).ParentColumnName = "SuperID";
                            }
                        }
                        break;
                    }
                    #endregion

                    control.ID      = _tablemodel.ModelClassName + "_" + _modelfieldsmodel.FieldName;
                    control.Enabled = _panel_modelfields.Enable.ToUpper() == "Y";

                    if (_panel_modelfields.ControlWidth > 0)
                    {
                        control.Width = _panel_modelfields.ControlWidth;
                    }

                    tc_control.Controls.Add(control);

                    #region 如果是文本框时,加上输入验证控件
                    if (_panel_modelfields.IsRequireField == "Y")
                    {
                        Label lbl_reqinfo = new Label();
                        lbl_reqinfo.Text      = "&nbsp;&nbsp;*";
                        lbl_reqinfo.ForeColor = System.Drawing.Color.Red;
                        tc_control.Controls.Add(lbl_reqinfo);
                    }

                    if (_panel_modelfields.ControlType == 2 || _panel_modelfields.ControlType == 5)
                    {
                        if (_panel_modelfields.IsRequireField == "Y")
                        {
                            RequiredFieldValidator _requiredfieldvalidator = new RequiredFieldValidator();
                            _requiredfieldvalidator.ControlToValidate = control.ID;
                            _requiredfieldvalidator.Display           = ValidatorDisplay.Dynamic;
                            _requiredfieldvalidator.ErrorMessage      = "必填";
                            _requiredfieldvalidator.ForeColor         = System.Drawing.Color.Red;
                            _requiredfieldvalidator.ValidationGroup   = _validationgroup;

                            tc_control.Controls.Add(_requiredfieldvalidator);
                        }

                        if (_panel_modelfields.RegularExpression != "")
                        {
                            RegularExpressionValidator _regularexpressionvalidator = new RegularExpressionValidator();
                            _regularexpressionvalidator.ControlToValidate    = control.ID;
                            _regularexpressionvalidator.ErrorMessage         = "数据格式不正确";
                            _regularexpressionvalidator.ForeColor            = System.Drawing.Color.Red;
                            _regularexpressionvalidator.ValidationExpression = _panel_modelfields.RegularExpression;
                            _regularexpressionvalidator.ValidationGroup      = ValidationGroup;
                            _regularexpressionvalidator.Display = ValidatorDisplay.Dynamic;
                            tc_control.Controls.Add(_regularexpressionvalidator);
                        }
                        else
                        {
                            if (_modelfieldsmodel.DataType == 1 || _modelfieldsmodel.DataType == 2 || _modelfieldsmodel.DataType == 4)        //非varchar 字符串
                            {
                                CompareValidator _comparevalidator = new CompareValidator();
                                _comparevalidator.ControlToValidate = control.ID;
                                _comparevalidator.Operator          = ValidationCompareOperator.DataTypeCheck;
                                _comparevalidator.Display           = ValidatorDisplay.Dynamic;
                                _comparevalidator.ForeColor         = System.Drawing.Color.Red;
                                _comparevalidator.ValidationGroup   = _validationgroup;

                                if (_modelfieldsmodel.DataType == 1)//int
                                {
                                    _comparevalidator.Type         = ValidationDataType.Integer;
                                    _comparevalidator.ErrorMessage = "应为整数";
                                }
                                if (_modelfieldsmodel.DataType == 2)//decimal
                                {
                                    _comparevalidator.Type         = ValidationDataType.Double;
                                    _comparevalidator.ErrorMessage = "应为数字";
                                }
                                if (_modelfieldsmodel.DataType == 4)//datetime
                                {
                                    _comparevalidator.Type         = ValidationDataType.Date;
                                    _comparevalidator.ErrorMessage = "日期格式不正确";
                                }
                                tc_control.Controls.Add(_comparevalidator);
                            }
                        }
                    }
                    #endregion

                    if (!string.IsNullOrEmpty(_panel_modelfields.Description))
                    {
                        Label lb = new Label();
                        lb.Text = "  " + _panel_modelfields.Description;
                        tc_control.Controls.Add(lb);
                    }

                    tr_panel_detail.Cells.Add(tc_control);
                    #endregion

                    #region 将控件记录到字段控件HashTable中
                    FieldControlInfo fieldcontrolinfo = new FieldControlInfo();

                    fieldcontrolinfo.FieldID        = _modelfieldsmodel.ID;
                    fieldcontrolinfo.FieldName      = _modelfieldsmodel.FieldName;
                    fieldcontrolinfo.ModelName      = _tablemodel.ModelClassName;
                    fieldcontrolinfo.ControlType    = _panel_modelfields.ControlType;
                    fieldcontrolinfo.ControlName    = control.ID;
                    fieldcontrolinfo.DisplayMode    = _panel_modelfields.DisplayMode;
                    fieldcontrolinfo.Panel_Field_ID = _panel_modelfields.ID;
                    _htFieldControlsInfo.Add(fieldcontrolinfo.ControlName, fieldcontrolinfo);
                    #endregion
                }
                #endregion

                tc_panel.Controls.Add(tb_panel_content);
                tr_panel.Cells.Add(tc_panel);
                T_Content.Rows.Add(tr_panel);
            }
            ViewState["FieldControlsInfo"] = _htFieldControlsInfo;
        }
Example #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CompareValidator validator = ((CompareValidator)(FormView1.FindControl("CompareEndTodayValidator")));

            validator.ValueToCompare = DateTime.Now.ToShortDateString();
        }
        protected void rptCustomFields_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var currentField = (UserCustomField)e.Item.DataItem;

            var ph   = (PlaceHolder)e.Item.FindControl("PlaceHolder");
            var id   = (HiddenField)e.Item.FindControl("Id");
            var name = (HiddenField)e.Item.FindControl("Name");

            id.Value   = currentField.Id.ToString();
            name.Value = currentField.Name;

            switch (currentField.FieldType)
            {
            case CustomFieldType.DropDownList:

                var ddl = new DropDownList
                {
                    ID             = FIELD_VALUE_NAME,
                    DataSource     = UserCustomFieldSelectionManager.GetByCustomFieldId(currentField.Id),
                    DataTextField  = "Name",
                    DataValueField = "Value",
                    CssClass       = "form-control"
                };

                ddl.DataBind();
                ddl.Items.Insert(0, new ListItem("-- Select One --", string.Empty));
                ddl.SelectedValue = currentField.Value;

                ph.Controls.Add(ddl);

                if (IsLocked)
                {
                    ddl.Enabled = false;
                }

                break;

            case CustomFieldType.Date:

                var fieldValue1 = new TextBox();
                fieldValue1.Attributes.Add("bn-data-type", "date");
                var cal = new CalendarExtender();

                var img = new Image {
                    ID = "calImage", CssClass = "icon", ImageUrl = "~/images/calendar.gif"
                };

                cal.PopupButtonID   = "calImage";
                cal.TargetControlID = FIELD_VALUE_NAME;
                cal.ID = "Calendar1";

                fieldValue1.ID    = "FieldValue";
                fieldValue1.Width = 80;

                ph.Controls.Add(fieldValue1);
                ph.Controls.Add(img);
                ph.Controls.Add(new LiteralControl("&nbsp"));

                DateTime dt;
                var      dateTimeValue = currentField.Value;

                if (DateTime.TryParse(dateTimeValue, out dt))
                {
                    dateTimeValue = dt.ToShortDateString();
                }

                fieldValue1.Text = dateTimeValue;

                ph.Controls.Add(cal);

                if (IsLocked)
                {
                    cal.Enabled         = false;
                    fieldValue1.Enabled = false;
                    img.Visible         = false;
                }
                break;

            case CustomFieldType.Text:

                var fieldValue = new TextBox
                {
                    ID       = FIELD_VALUE_NAME,
                    Text     = currentField.Value,
                    CssClass = "form-control"
                };
                fieldValue.Attributes.Add("bn-data-type", "text");

                ph.Controls.Add(fieldValue);

                if (currentField.Value.Trim().ToLower().StartsWith("http"))
                {
                    var url = new HyperLink {
                        Target = "_blank", NavigateUrl = currentField.Value, Text = "&nbsp;GOTO >>"
                    };
                    ph.Controls.Add(url);
                }

                if (IsLocked)
                {
                    fieldValue.Enabled = false;
                }
                break;

            case CustomFieldType.YesNo:

                var chk = new CheckBox {
                    ID = FIELD_VALUE_NAME
                };

                if (!String.IsNullOrEmpty(currentField.Value))
                {
                    chk.Checked = Boolean.Parse(currentField.Value);
                }

                ph.Controls.Add(new LiteralControl("<div class=\"checkbox\">"));
                ph.Controls.Add(chk);
                ph.Controls.Add(new LiteralControl("</div>"));

                if (IsLocked)
                {
                    chk.Enabled = false;
                }

                break;

            case CustomFieldType.RichText:

                var editor = new HtmlEditor {
                    ID = FIELD_VALUE_NAME
                };
                editor.Attributes.Add("bn-data-type", "html");

                ph.Controls.Add(editor);

                editor.Text = currentField.Value;

                break;

            case CustomFieldType.UserList:

                ddl = new DropDownList
                {
                    ID             = FIELD_VALUE_NAME,
                    DataSource     = UserManager.GetAllUsers(),
                    DataTextField  = "DisplayName",
                    DataValueField = "UserName",
                    CssClass       = "form-control"
                };

                ddl.DataBind();

                ddl.Items.Insert(0, new ListItem(GetGlobalResourceObject("SharedResources", "DropDown_SelectOne").ToString(), string.Empty));
                ddl.SelectedValue = currentField.Value;

                ph.Controls.Add(ddl);

                if (IsLocked)
                {
                    ddl.Enabled = false;
                }

                break;
            }

            var lblFieldName = (Label)e.Item.FindControl("lblFieldName");

            lblFieldName.AssociatedControlID = FIELD_VALUE_NAME;
            lblFieldName.Text = currentField.Name;

            if (EnableValidation)
            {
                //if required dynamically add a required field validator
                if (currentField.Required && currentField.FieldType != CustomFieldType.YesNo)
                {
                    var valReq = new RequiredFieldValidator
                    {
                        ControlToValidate = FIELD_VALUE_NAME,
                        Text            = string.Format(" ({0})", GetGlobalResourceObject("SharedResources", "Required")).ToLower(),
                        Display         = ValidatorDisplay.Dynamic,
                        CssClass        = "text-danger validation-error",
                        SetFocusOnError = true
                    };

                    if (currentField.FieldType == CustomFieldType.DropDownList)
                    {
                        valReq.InitialValue = string.Empty;
                    }

                    ph.Controls.Add(valReq);
                }

                //create data type check validator
                if (currentField.FieldType != CustomFieldType.YesNo)
                {
                    var valCompare = new CompareValidator
                    {
                        Type              = currentField.DataType,
                        Text              = String.Format("({0})", currentField.DataType),
                        Operator          = ValidationCompareOperator.DataTypeCheck,
                        Display           = ValidatorDisplay.Dynamic,
                        ControlToValidate = FIELD_VALUE_NAME
                    };
                    ph.Controls.Add(valCompare);
                }
            }
        }
 public override bool IsValid(object value)
 {
     return(CompareValidator.IsValidRelativeToZero(ComparisonOperator.GreaterThan, value));
 }
        //Writes controls to page when editing
        protected override void CreateChildControls()
        {
            #region licensing
            SPWeb      web     = SPContext.Current.Web;
            WebRequest request = WebRequest.Create(web.Url + "/_layouts/SprocketValidator/key.xml");
            request.Credentials = CredentialCache.DefaultCredentials;
            WebResponse   response = request.GetResponse();
            XmlTextReader reader   = new XmlTextReader(response.GetResponseStream());
            reader.ReadToFollowing("key");
            reader.Read();

            string   key        = System.Text.Encoding.ASCII.GetString(Convert.FromBase64String(reader.Value));
            string[] values     = key.Split(new char[] { '|' });
            DateTime expireDate = DateTime.ParseExact(values[values.Length - 1], "yyyyMMdd", CultureInfo.InvariantCulture);

            //HERE - does this need to change?
            if (!values.Contains <string>("*") && (DateTime.Now > expireDate || !values.Contains <string>(System.Environment.MachineName)))
            {
                base.CreateChildControls();
                tb_ValidatedInput     = new TextBox();
                tb_ValidatedInput.ID  = "tb_ValidatedInput";
                lbl_Instructions      = new Label();
                lbl_Instructions.ID   = "lbl_Instructions";
                lbl_Instructions.Text = "<b>The license for this product has expired or is invalid</b>";
                this.Controls.Add(lbl_Instructions);
                return;
            }
            #endregion

            base.CreateChildControls();
            tb_ValidatedInput     = new TextBox();
            tb_ValidatedInput.ID  = "tb_ValidatedInput";
            lbl_Instructions      = new Label();
            lbl_Instructions.ID   = "lbl_Instructions";
            lbl_Instructions.Text = "<br/><i>" + field.GetFieldAttribute("Instructions") + "</i>";

            this.Controls.Add(tb_ValidatedInput);

            int validationType;
            int.TryParse(field.GetFieldAttribute("ValidationType"), out validationType);
            switch ((ValidatedInput.ValidationTypes)validationType)
            {
            case ValidatedInput.ValidationTypes.Masked:
                tb_ValidatedInput.Attributes.Add("onfocus", "$(this).mask('" + field.GetFieldAttribute("Mask") + "')");
                break;

            case ValidatedInput.ValidationTypes.Regex:
                regexVal = new RegularExpressionValidator();
                regexVal.ValidationExpression = field.GetFieldAttribute("Regex") ?? string.Empty;
                regexVal.ControlToValidate    = "tb_ValidatedInput";
                regexVal.Text = "Input invalid!";
                this.Controls.Add(regexVal);
                break;

            case ValidatedInput.ValidationTypes.Value:

                rangeVal     = new RangeValidator();
                customVal    = new CustomValidator();
                compareVal   = new CompareValidator();
                typeCheckVal = new CompareValidator();

                compareVal.ControlToValidate   = "tb_ValidatedInput";
                rangeVal.ControlToValidate     = "tb_ValidatedInput";
                customVal.ControlToValidate    = "tb_ValidatedInput";
                typeCheckVal.ControlToValidate = "tb_ValidatedInput";
                typeCheckVal.Operator          = ValidationCompareOperator.DataTypeCheck;

                string value        = field.GetFieldAttribute("ComparisonValue");
                string errorMessage = "Your value must ";
                string dataType     = field.GetFieldAttribute("ComparisonDataType");

                switch (dataType)
                {
                case "Number":
                    //rangeVal.Type = ValidationDataType.Double;
                    compareVal.Type           = ValidationDataType.Double;
                    typeCheckVal.Type         = ValidationDataType.Double;
                    typeCheckVal.ErrorMessage = "You must enter a number<br/>";
                    this.Controls.Add(typeCheckVal);
                    break;

                case "Date":
                    //rangeVal.Type = ValidationDataType.Date;
                    compareVal.Type           = ValidationDataType.Date;
                    typeCheckVal.Type         = ValidationDataType.Date;
                    typeCheckVal.ErrorMessage = "You must enter a date<br/>";
                    this.Controls.Add(typeCheckVal);
                    break;

                default:
                    //rangeVal.Type = ValidationDataType.String;
                    compareVal.Type = ValidationDataType.String;
                    //typeCheckVal.Type = ValidationDataType.String;
                    //typeCheckVal.ErrorMessage = "You must enter a word or words";
                    break;
                }

                switch (field.GetFieldAttribute("Comparison"))
                {
                case "Be Greater Than...":
                    errorMessage             += "be greater than: " + value;
                    compareVal.ErrorMessage   = errorMessage;
                    compareVal.Operator       = ValidationCompareOperator.GreaterThan;
                    compareVal.ValueToCompare = value;
                    this.Controls.Add(compareVal);
                    break;

                case "Be Less Than...":
                    errorMessage             += "be less than: " + value;
                    compareVal.ErrorMessage   = errorMessage;
                    compareVal.Operator       = ValidationCompareOperator.LessThan;
                    compareVal.ValueToCompare = value;
                    this.Controls.Add(compareVal);
                    break;

                case "Start With...":
                    errorMessage             += "start with: " + value;
                    customVal.ErrorMessage    = errorMessage;
                    customVal.ServerValidate += StartsWith;
                    this.Controls.Add(customVal);
                    break;

                case "End With...":
                    errorMessage             += "end with: " + value;
                    customVal.ErrorMessage    = errorMessage;
                    customVal.ServerValidate += EndsWith;
                    this.Controls.Add(customVal);
                    break;

                case "Contain...":
                default:
                    errorMessage             += "contain: " + value;
                    customVal.ErrorMessage    = errorMessage;
                    customVal.ServerValidate += Contains;
                    this.Controls.Add(customVal);
                    break;
                }

                break;
            }

            this.Controls.Add(lbl_Instructions);
        }
Example #25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            TextBox nickNameBox = new TextBox()
            {
                ID = "nickNameBox"
            };
            TextBox nameBox = new TextBox()
            {
                ID = "nameBox"
            };
            TextBox sirNameBox = new TextBox()
            {
                ID = "sirNameBox"
            };
            TextBox emailBox = new TextBox {
                ID = "emailBox"
            };
            Label registrationFormLabel = new Label {
                Text = "Registration form:"
            };
            Label nicknameLabel = new Label {
                Text = "Nick Name:"
            };
            Label nameLabel = new Label {
                Text = "First name:"
            };
            Label sirnameLabel = new Label {
                Text = "Last name:"
            };
            Label dateOfBirthLabel = new Label {
                Text = "Date of birth:"
            };
            Label emailLabel = new Label {
                Text = "E-mail:"
            };
            Label countryLabel = new Label {
                Text = "Country:"
            };
            Label cityLabel = new Label {
                Text = "City:"
            };
            Label validationSummaryLabel = new Label {
                Text = "Validation Summary:"
            };

            RegularExpressionValidator emailvalidator = new RegularExpressionValidator()
            {
                ValidationExpression = @"[a-zA-Z_0-9.-]+\@[a-zA-Z_0-9.-]+\.\w+", ControlToValidate = "emailBox", ForeColor = Color.Crimson, ErrorMessage = "Enter correct email please..."
            };
            RequiredFieldValidator requiredEmail = new RequiredFieldValidator()
            {
                ControlToValidate = "emailBox", ForeColor = Color.Crimson, ErrorMessage = "Enter e-mail please..."
            };
            RequiredFieldValidator requiredCountry = new RequiredFieldValidator()
            {
                ControlToValidate = "country", ForeColor = Color.Crimson, ErrorMessage = "Select country please..."
            };
            RequiredFieldValidator requiredCity = new RequiredFieldValidator()
            {
                ControlToValidate = "city", ForeColor = Color.Crimson, ErrorMessage = "Select city please..."
            };
            RequiredFieldValidator requiredNickname = new RequiredFieldValidator()
            {
                ControlToValidate = "nickNameBox", ForeColor = Color.Crimson, ErrorMessage = "Enter nickname please..."
            };
            RequiredFieldValidator requiredName = new RequiredFieldValidator()
            {
                ControlToValidate = "nameBox", ForeColor = Color.Crimson, ErrorMessage = "Enter first name please..."
            };
            RequiredFieldValidator requiredSirname = new RequiredFieldValidator()
            {
                ControlToValidate = "sirNameBox", ForeColor = Color.Crimson, ErrorMessage = "Enter last name please..."
            };
            RequiredFieldValidator requiredDate = new RequiredFieldValidator()
            {
                ControlToValidate = "birthDateBox", ForeColor = Color.Crimson, ErrorMessage = "Select the date please..."
            };
            CompareValidator nameToNick = new CompareValidator()
            {
                ControlToValidate = "nameBox", ControlToCompare = "nickNameBox", Operator = ValidationCompareOperator.NotEqual, ForeColor = Color.Crimson, ErrorMessage = "Shouldn`t be equal to nickname!"
            };
            CompareValidator sirnameToName = new CompareValidator()
            {
                ControlToValidate = "sirNameBox", ControlToCompare = "nameBox", Operator = ValidationCompareOperator.NotEqual, ForeColor = Color.Crimson, ErrorMessage = "Shouldn`t be equal to name!"
            };
            RangeValidator dateValidator = new RangeValidator()
            {
                ControlToValidate = "birthDateBox", MinimumValue = new DateTime(1960, 12, 1).ToShortDateString(), MaximumValue = DateTime.Now.ToShortDateString(), Type = ValidationDataType.Date, ForeColor = Color.Crimson, ErrorMessage = "Date of birth should be between 12/1/1960 and " + DateTime.Now.ToShortDateString()
            };
            CompareValidator notDefaultCountry = new CompareValidator()
            {
                ControlToValidate = "country", ValueToCompare = "Choose from there", Operator = ValidationCompareOperator.NotEqual, ForeColor = Color.Crimson, ErrorMessage = "Please select country!"
            };
            CompareValidator notDefaultCity = new CompareValidator()
            {
                ControlToValidate = "city", ValueToCompare = "Choose country first", Operator = ValidationCompareOperator.NotEqual, ForeColor = Color.Crimson, ErrorMessage = "Please, select city!"
            };

            ValidationSummary summary = new ValidationSummary()
            {
                ForeColor = Color.Crimson
            };

            Button submitButton = new Button();

            registrationFormLabel.Style["Position"] = "Absolute";
            registrationFormLabel.Style["Top"]      = "25px";
            registrationFormLabel.Style["Left"]     = "100px";
            registrationFormLabel.Font.Size         = 24;
            registrationFormLabel.Font.Bold         = true;

            nicknameLabel.Style["Position"]    = "Absolute";
            nicknameLabel.Style["Top"]         = "90px";
            nicknameLabel.Style["Left"]        = "100px";
            nickNameBox.Style["Position"]      = "Absolute";
            nickNameBox.Style["Top"]           = "90px";
            nickNameBox.Style["Left"]          = "250px";
            requiredNickname.Style["Position"] = "Absolute";
            requiredNickname.Style["Top"]      = "90px";
            requiredNickname.Style["Left"]     = "550px";

            nameLabel.Style["Position"]    = "Absolute";
            nameLabel.Style["Top"]         = "125px";
            nameLabel.Style["Left"]        = "100px";
            nameBox.Style["Position"]      = "Absolute";
            nameBox.Style["Top"]           = "125px";
            nameBox.Style["Left"]          = "250px";
            requiredName.Style["Position"] = "Absolute";
            requiredName.Style["Top"]      = "125px";
            requiredName.Style["Left"]     = "550px";
            nameToNick.Style["Position"]   = "Absolute";
            nameToNick.Style["Top"]        = "125px";
            nameToNick.Style["Left"]       = "550px";

            sirnameLabel.Style["Position"]    = "Absolute";
            sirnameLabel.Style["Top"]         = "160px";
            sirnameLabel.Style["Left"]        = "100px";
            sirNameBox.Style["Position"]      = "Absolute";
            sirNameBox.Style["Top"]           = "160px";
            sirNameBox.Style["Left"]          = "250px";
            requiredSirname.Style["Position"] = "Absolute";
            requiredSirname.Style["Top"]      = "160px";
            requiredSirname.Style["Left"]     = "550px";
            sirnameToName.Style["Position"]   = "Absolute";
            sirnameToName.Style["Top"]        = "160px";
            sirnameToName.Style["Left"]       = "550px";

            dateOfBirthLabel.Style["Position"] = "Absolute";
            dateOfBirthLabel.Style["Top"]      = "195px";
            dateOfBirthLabel.Style["Left"]     = "100px";
            birthDateBox.Style["Position"]     = "Absolute";
            birthDateBox.Style["Top"]          = "195px";
            birthDateBox.Style["Left"]         = "250px";
            calendar.Style["Position"]         = "Absolute";
            calendar.Style["Top"]           = "230px";
            calendar.Style["Left"]          = "250px";
            calendar.SelectionChanged      += Calendar1_SelectionChanged;
            dateValidator.Style["Position"] = "Absolute";
            dateValidator.Style["Top"]      = "195px";
            dateValidator.Style["Left"]     = "550px";
            requiredDate.Style["Position"]  = "Absolute";
            requiredDate.Style["Top"]       = "195px";
            requiredDate.Style["Left"]      = "550px";

            emailLabel.Style["Position"]     = "Absolute";
            emailLabel.Style["Top"]          = "425px";
            emailLabel.Style["Left"]         = "100px";
            emailBox.Style["Position"]       = "Absolute";
            emailBox.Style["Top"]            = "425px";
            emailBox.Style["Left"]           = "250px";
            emailvalidator.Style["Position"] = "Absolute";
            emailvalidator.Style["Top"]      = "425px";
            emailvalidator.Style["Left"]     = "550px";
            requiredEmail.Style["Position"]  = "Absolute";
            requiredEmail.Style["Top"]       = "425px";
            requiredEmail.Style["Left"]      = "550px";

            countryLabel.Style["Position"]      = "Absolute";
            countryLabel.Style["Top"]           = "460px";
            countryLabel.Style["Left"]          = "100px";
            country.Style["Position"]           = "Absolute";
            country.Style["Top"]                = "460px";
            country.Style["Left"]               = "250px";
            requiredCountry.Style["Position"]   = "Absolute";
            requiredCountry.Style["Top"]        = "460px";
            requiredCountry.Style["Left"]       = "550px";
            notDefaultCountry.Style["Position"] = "Absolute";
            notDefaultCountry.Style["Top"]      = "460px";
            notDefaultCountry.Style["Left"]     = "550px";
            country.Items.Add(new ListItem("Choose from there", "Choose from there"));
            country.Items.Add(new ListItem("Ukraine", "Ukraine"));
            country.Items.Add(new ListItem("Chech Republic", "Chech Republic"));
            country.SelectedIndexChanged += Country_ChangeSelection;
            country.AutoPostBack          = true;

            cityLabel.Style["Position"]    = "Absolute";
            cityLabel.Style["Top"]         = "495px";
            cityLabel.Style["Left"]        = "100px";
            city.Style["Position"]         = "Absolute";
            city.Style["Top"]              = "495px";
            city.Style["Left"]             = "250px";
            requiredCity.Style["Position"] = "Absolute";
            requiredCity.Style["Top"]      = "495px";
            requiredCity.Style["Left"]     = "550px";
            city.Items.Add(new ListItem("Choose country first", "Choose country first"));
            notDefaultCity.Style["Position"] = "Absolute";
            notDefaultCity.Style["Top"]      = "495px";
            notDefaultCity.Style["Left"]     = "550px";

            validationSummaryLabel.Style["Position"] = "Absolute";
            validationSummaryLabel.Style["Top"]      = "530px";
            validationSummaryLabel.Style["Left"]     = "100px";
            summary.Style["Position"] = "Absolute";
            summary.Style["Top"]      = "530px";
            summary.Style["Left"]     = "250px";

            submitButton.Style["Position"] = "Absolute";
            submitButton.Style["Top"]      = "600px";
            submitButton.Style["Left"]     = "100px";
            submitButton.Text   = "Submit";
            submitButton.Click += submitButton_Click;


            form1.Controls.Add(nickNameBox);
            form1.Controls.Add(nameBox);
            form1.Controls.Add(sirNameBox);
            form1.Controls.Add(birthDateBox);
            form1.Controls.Add(calendar);
            form1.Controls.Add(emailBox);
            form1.Controls.Add(country);
            form1.Controls.Add(city);
            form1.Controls.Add(submitButton);
            form1.Controls.Add(summary);
            form1.Controls.Add(registrationFormLabel);
            form1.Controls.Add(nicknameLabel);
            form1.Controls.Add(nameLabel);
            form1.Controls.Add(sirnameLabel);
            form1.Controls.Add(dateOfBirthLabel);
            form1.Controls.Add(emailLabel);
            form1.Controls.Add(countryLabel);
            form1.Controls.Add(cityLabel);
            form1.Controls.Add(validationSummaryLabel);
            form1.Controls.Add(emailvalidator);
            form1.Controls.Add(requiredEmail);
            form1.Controls.Add(requiredNickname);
            form1.Controls.Add(requiredName);
            form1.Controls.Add(requiredSirname);
            form1.Controls.Add(nameToNick);
            form1.Controls.Add(sirnameToName);
            form1.Controls.Add(dateValidator);
            form1.Controls.Add(requiredDate);
            form1.Controls.Add(requiredCountry);
            form1.Controls.Add(requiredCity);
            form1.Controls.Add(notDefaultCountry);
            form1.Controls.Add(notDefaultCity);
        }
Example #26
0
        protected override void CreateChildControls()
        {
            Controls.Clear();

            lblOldPassword       = new Label();
            lblNewPassword       = new Label();
            lblRepeatNewPassword = new Label();

            tbNewPassword    = new TextBox();
            tbNewPassword.ID = "tbNewPassword";
            tbNewPassword.ValidationGroup = validationGroup;
            tbNewPassword.ClientIDMode    = ClientIDMode.Static;
            tbNewPassword.TextMode        = TextBoxMode.Password;

            tbOldPassword    = new TextBox();
            tbOldPassword.ID = "tbOldPassword";
            tbOldPassword.ValidationGroup = validationGroup;
            tbOldPassword.ClientIDMode    = ClientIDMode.Static;
            tbOldPassword.TextMode        = TextBoxMode.Password;

            tbRepeatNewPassword    = new TextBox();
            tbRepeatNewPassword.ID = "tbRepeatNewPassword";
            tbRepeatNewPassword.ValidationGroup = validationGroup;
            tbRepeatNewPassword.ClientIDMode    = ClientIDMode.Static;
            tbRepeatNewPassword.TextMode        = TextBoxMode.Password;

            rfvOldPassword = new RequiredFieldValidator();
            rfvOldPassword.ControlToValidate = tbOldPassword.ID;
            rfvOldPassword.ValidationGroup   = validationGroup;
            rfvOldPassword.Display           = ValidatorDisplay.Dynamic;

            rfvNewPassword = new RequiredFieldValidator();
            rfvNewPassword.ControlToValidate = tbNewPassword.ID;
            rfvNewPassword.ValidationGroup   = validationGroup;
            rfvNewPassword.Display           = ValidatorDisplay.Dynamic;

            rfvRepeatNewPassword = new RequiredFieldValidator();
            rfvRepeatNewPassword.ControlToValidate = tbRepeatNewPassword.ID;
            rfvRepeatNewPassword.ValidationGroup   = validationGroup;
            rfvRepeatNewPassword.Display           = ValidatorDisplay.Dynamic;

            cvRepeatNewPassword = new CompareValidator();
            cvRepeatNewPassword.ControlToValidate = tbRepeatNewPassword.ID;
            cvRepeatNewPassword.ControlToCompare  = tbNewPassword.ID;
            cvRepeatNewPassword.ValidationGroup   = validationGroup;
            cvRepeatNewPassword.Display           = ValidatorDisplay.Dynamic;

            cvOldPassword = new CustomValidator();
            cvOldPassword.ControlToValidate = tbOldPassword.ID;
            cvOldPassword.ValidationGroup   = validationGroup;
            cvOldPassword.Display           = ValidatorDisplay.Dynamic;

            lbtnSubmitButton                 = new LinkButton();
            lbtnSubmitButton.ID              = "lbtnPasswordChange";
            lbtnSubmitButton.Click          += new EventHandler(lbtnSubmitButton_Click);
            lbtnSubmitButton.ValidationGroup = validationGroup;

            this.Controls.Add(lblOldPassword);
            this.Controls.Add(tbOldPassword);
            this.Controls.Add(rfvOldPassword);
            this.Controls.Add(cvOldPassword);
            this.Controls.Add(lblNewPassword);
            this.Controls.Add(tbNewPassword);
            this.Controls.Add(rfvNewPassword);
            this.Controls.Add(lblRepeatNewPassword);
            this.Controls.Add(tbRepeatNewPassword);
            this.Controls.Add(rfvRepeatNewPassword);
            this.Controls.Add(cvRepeatNewPassword);
            this.Controls.Add(lbtnSubmitButton);
        }
Example #27
0
        public virtual WebControl RenderInEditor()
        {
            if (column.IsCDDExtender || column.IsTextChangeExtender)
            {
                return(null);
            }
            if (!column.IsEditable || column.IsStatic)
            {
                Label lbl = new Label();
                lbl.Width = new Unit(100, UnitType.Percentage);
                if (column.IsStatic)
                {
                    lbl.Text = column.Text;
                }
                else
                {
                    lbl.DataBinding += new EventHandler(lbl_DataBinding);
                }
                return(lbl);
            }
            if (column.IsLookup)
            {
                DropDownList ddl = new DropDownList();
                ddl.Width                 = new Unit(100, UnitType.Percentage);
                ddl.DataBinding          += new EventHandler(ddl_DataBinding);
                ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged);
                IDictionary <object, string> dictionary = lookup.GetLookup(column.Lookup);
                foreach (object key in dictionary.Keys)
                {
                    ListItem item = new ListItem(dictionary[key], key.ToString());
                    ddl.Items.Add(item);
                }
                var validationRule = from rule in column.Rules
                                     where (rule.ValidationType == "Required") && ((RequiredValidationRule)rule).IsRequired
                                     select rule;
                if (validationRule.Count() == 0)
                {
                    ddl.Items.Add(new ListItem(string.Empty, NullFinder.GetNullValue(column.DataType).ToString()));
                }
                ddl.ID = string.Format("ddl{0}", column.Name);
                return(ddl);
            }
            if (column.IsCascadedLookup)// || column.IsCDDExtended)
            {
                DropDownList ddl = new DropDownList();
                ddl.ID    = string.Format("ddl{0}", column.Name);
                ddl.Width = new Unit(100, UnitType.Percentage);
                ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged);
                return(ddl);
            }
            else
            {
                Panel   ph  = new Panel();
                TextBox txt = new TextBox();
                txt.Width        = new Unit(100, UnitType.Percentage);
                txt.DataBinding += new EventHandler(txt_DataBinding);
                txt.TextChanged += new EventHandler(txt_TextChanged);
                txt.ID           = string.Format("txt{0}", column.Name);
                if (column.IsLongText)
                {
                    txt.TextMode = TextBoxMode.MultiLine;
                }

                ph.Controls.Add(txt);
                //for each rule specified in the column descriptor
                //the renderer attaches the appropriate validator control
                foreach (ValidationRule rule in column.Rules)
                {
                    BaseValidator validationControl = null;
                    switch (rule.ValidationType)
                    {
                    case "Required":
                        if (((RequiredValidationRule)rule).IsRequired)
                        {
                            validationControl = new RequiredFieldValidator();
                        }
                        break;

                    case "Pattern":
                        RegularExpressionValidator validator = new RegularExpressionValidator();
                        validator.ValidationExpression = ((PatternValidationRule)rule).Pattern;
                        validationControl = validator;
                        break;

                    case "Range":
                        RangeValidator      rangeValidator = new RangeValidator();
                        RangeValidationRule rangeRule      = (RangeValidationRule)rule;
                        rangeValidator.MinimumValue = rangeRule.LeftBoundary;
                        rangeValidator.MaximumValue = rangeRule.RightBoundary;
                        validationControl           = rangeValidator;
                        break;

                    case "Compare":
                        CompareValidator      compareValidator = new CompareValidator();
                        CompareValidationRule compareRule      = (CompareValidationRule)rule;
                        compareValidator.Operator       = compareRule.CompareOperator;
                        compareValidator.Type           = compareRule.RuleDataType;
                        compareValidator.ValueToCompare = compareRule.ValueToCompare;
                        validationControl = compareValidator;
                        break;
                    }
                    if (validationControl != null)
                    {
                        validationControl.ValidationGroup   = "GINDataEditor";
                        validationControl.ControlToValidate = txt.ID;
                        validationControl.ErrorMessage      = rule.ErrorMessage;
                        validationControl.Text = "*";
                        ph.Controls.Add(validationControl);
                    }
                }
                return(ph);
            }
        }
        public override void CreateChildControls()
        {
            // If user trying to visit settings screen, they must be logged on
            if (_userAction == "settings" && LoggedOnUserID == 0)
            {
                RedirectToLoginPage();
            }

            // Alias text box
            _aliasTextBox           = new TextBox();
            _aliasTextBox.ID        = "_aliasTextBox";
            _aliasTextBox.Width     = Unit.Pixel(150);
            _aliasTextBox.MaxLength = 100;
            _aliasTextBox.CssClass  = "WebSolutionFormControl";

            // Alias validator
            _aliasValidator = new ValidAlias();
            _aliasValidator.ControlToValidate = "_aliasTextBox";
            _aliasValidator.CssClass          = "WebSolutionFormControl";

            // Email entry row
            _emailTextBox           = new TextBox();
            _emailTextBox.ID        = "_emailTextBox";
            _emailTextBox.Width     = Unit.Pixel(150);
            _emailTextBox.MaxLength = 100;
            _emailTextBox.CssClass  = "WebSolutionFormControl";

            // Email validator
            _emailValidator = new ValidEmail();
            _emailValidator.ControlToValidate = "_emailTextBox";
            _emailValidator.CssClass          = "WebSolutionFormControl";

            // CHANGED by Arthur Zaczek

/**
 *                      // Password entry row
 *                      _passwordTextBox = new TextBox();
 *                      _passwordTextBox.ID = "_passwordTextBox";
 *                      _passwordTextBox.Width = Unit.Pixel(150);
 *                      _passwordTextBox.MaxLength = 50;
 *                      _passwordTextBox.TextMode = TextBoxMode.Password;
 *                      _passwordTextBox.CssClass = "WebSolutionFormControl";
 *
 *                      // Password validator
 *                      _passwordValidator = new ValidPassword();
 *                      _passwordValidator.ControlToValidate = "_passwordTextBox";
 *                      _passwordValidator.CssClass = "WebSolutionFormControl";
 *
 *                      // Password confirm entry row
 *                      _confirmTextBox = new TextBox();
 *                      _confirmTextBox.ID = "_confirmTextBox";
 *                      _confirmTextBox.Width = Unit.Pixel(150);
 *                      _confirmTextBox.MaxLength = 50;
 *                      _confirmTextBox.TextMode = TextBoxMode.Password;
 *                      _confirmTextBox.CssClass = "WebSolutionFormControl";*/

            // Confirm validator
            _confirmValidator                   = new CompareValidator();
            _confirmValidator.CssClass          = "WebSolutionFormControl";
            _confirmValidator.ControlToValidate = "_confirmTextBox";
            _confirmValidator.ControlToCompare  = "_passwordTextBox";
            _confirmValidator.ErrorMessage      = "Passwords must be identical.";
            _confirmValidator.Display           = ValidatorDisplay.Dynamic;

/*			// Confirm required field validator
 *                      _confirmRequiredValidator = new RequiredFieldValidator();
 *                      _confirmRequiredValidator.CssClass = "WebSolutionFormControl";
 *                      _confirmRequiredValidator.ControlToValidate = "_confirmTextBox";
 *                      _confirmRequiredValidator.ErrorMessage = "Please enter a password.";
 *                      _confirmRequiredValidator.Display = ValidatorDisplay.Dynamic;*/

            // Remember me check box
            _rememberMeCheckBox          = new CheckBox();
            _rememberMeCheckBox.Text     = "Remember me";
            _rememberMeCheckBox.CssClass = "WebSolutionFormControl";

            // Submit button
            _submitButton          = new Button();
            _submitButton.Text     = _userAction == "settings" ? "Save" : "Create Account";
            _submitButton.Click   += new System.EventHandler(SubmitButton_Click);
            _submitButton.CssClass = "WebSolutionFormControl";

            // Avatar
            _inputFile    = new HtmlInputFile();
            _inputFile.ID = "_inputFile";

            // Avatar validator
            _avatarValidator = new ValidAvatar();
            _avatarValidator.ControlToValidate = "_inputFile";
            _avatarValidator.InputFile         = _inputFile;
            _avatarValidator.CssClass          = "WebSolutionFormControl";

            // Add child controls
            Controls.Add(_aliasTextBox);
            Controls.Add(_aliasValidator);
            Controls.Add(_emailTextBox);
            Controls.Add(_emailValidator);
//			Controls.Add(_passwordTextBox);
//			Controls.Add(_passwordValidator);
//			Controls.Add(_confirmTextBox);
//			Controls.Add(_confirmValidator);
//			Controls.Add(_confirmRequiredValidator);
            Controls.Add(_rememberMeCheckBox);
            Controls.Add(_submitButton);
            Controls.Add(_inputFile);
            Controls.Add(_avatarValidator);

            // Populate controls with user settings?
            if (_userAction == "settings")
            {
                PopulateUserSettings();
            }
        }
    protected void BindMonthTemplates()
    {
        HtmlTable t = new HtmlTable();

        // break row
        HtmlTableRow  r     = new HtmlTableRow();
        HtmlTableCell clong = new HtmlTableCell()
        {
            ColSpan = 4
        };

        clong.Attributes.Add("style", "border-top:dotted 1px gray;");
        r.Cells.Add(clong);
        t.Rows.Add(r);

        // Header row
        r = new HtmlTableRow();
        HtmlTableCell c1 = new HtmlTableCell()
        {
            Width = "100"
        };
        HtmlTableCell c2 = new HtmlTableCell();
        HtmlTableCell c3 = new HtmlTableCell();
        HtmlTableCell c4 = new HtmlTableCell();

        c1.Controls.Add(new Label {
            Text = "Month", ForeColor = Color.Silver
        });
        c2.Controls.Add(new Label {
            Text = "Price", ForeColor = Color.Silver
        });
        c3.Controls.Add(new Label {
            Text = "Outstanding", ForeColor = Color.Silver
        });
        c4.Controls.Add(new Label {
            Text = "Invoice", ForeColor = Color.Silver
        });
        //c4.Controls.Add(new Label { Text = "Date Paid", ForeColor = Color.Silver });
        r.Cells.Add(c1);
        r.Cells.Add(c2);
        r.Cells.Add(c3);
        r.Cells.Add(c4);
        t.Rows.Add(r);

        //bool is_chrome = Util.IsBrowser(this, "safari");
        int this_month = dd_start_month.SelectedIndex;
        int this_year  = Convert.ToInt32(dd_start_year.SelectedItem.Text);

        for (int i = 0; i < dd_month_span.SelectedIndex + 1; i++)
        {
            r  = new HtmlTableRow();
            c1 = new HtmlTableCell();
            c2 = new HtmlTableCell();
            c3 = new HtmlTableCell();
            c4 = new HtmlTableCell();

            // Issue name
            String s_this_month   = "";
            int    this_month_idx = this_month;
            if (this_month_idx > dd_start_month.Items.Count - 1)
            {
                this_month_idx = 0;
                this_month     = 0;
                this_year++;
            }
            s_this_month = dd_start_month.Items[this_month_idx].Text + " " + this_year;
            this_month++;
            c1.Controls.Add(new Label()
            {
                Text = Server.HtmlEncode(s_this_month), ForeColor = Color.DarkOrange
            });

            // Price & Validator
            TextBox tb_price = new TextBox()
            {
                Width = 80, ID = ("prc" + i)
            };
            tb_price.Attributes.Add("onchange", "return updateTotalPrice();");
            c2.Controls.Add(tb_price);
            CompareValidator cv_prc = new CompareValidator();
            cv_prc.Operator          = ValidationCompareOperator.GreaterThan;
            cv_prc.Type              = ValidationDataType.Double;
            cv_prc.Display           = ValidatorDisplay.Dynamic;
            cv_prc.ErrorMessage      = "<br/>Not number";
            cv_prc.ForeColor         = Color.Red;
            cv_prc.ControlToValidate = "prc" + i;
            c2.Controls.Add(cv_prc);

            // Outstanding & Validator
            c3.Controls.Add(new TextBox()
            {
                ID = ("out" + i), Width = 80, ReadOnly = true, BackColor = Color.LightGray
            });
            CompareValidator cv_out = new CompareValidator();
            cv_out.Operator          = ValidationCompareOperator.GreaterThan;
            cv_out.Type              = ValidationDataType.Double;
            cv_out.Display           = ValidatorDisplay.Dynamic;
            cv_out.ErrorMessage      = "<br/>Not number";
            cv_out.ForeColor         = Color.Red;
            cv_out.ControlToValidate = "out" + i;
            c3.Controls.Add(cv_out);

            // Invoice
            c4.Controls.Add(new TextBox()
            {
                Width = 80, ReadOnly = true, BackColor = Color.LightGray
            });

            //RadDatePicker rdp = new RadDatePicker() { Width = 120 };
            //if (is_chrome)
            //    rdp.Attributes.Add("style", "position:relative; top:-4px;");
            //c4.Controls.Add(rdp);

            r.Cells.Add(c1);
            r.Cells.Add(c2);
            r.Cells.Add(c3);
            r.Cells.Add(c4);
            t.Rows.Add(r);
        }
        div_months.Controls.Clear();
        div_months.Controls.Add(t);
    }
Example #30
0
        internal static void AddNumberTextBox(HtmlTable htmlTable, string resourceClassName, string columnName, string label, string description,
                                              string defaultValue, bool isSerial, bool isNullable, int maxLength, string domain, string errorCssClass,
                                              bool disabled)
        {
            if (htmlTable == null)
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(columnName))
            {
                return;
            }

            using (TextBox textBox = ScrudTextBox.GetTextBox(columnName + "_textbox", maxLength))
            {
                if (!string.IsNullOrWhiteSpace(description))
                {
                    textBox.CssClass += " activating element";
                    textBox.Attributes.Add("data-content", description);
                }

                using (CompareValidator numberValidator = GetNumberValidator(textBox, domain, errorCssClass))
                {
                    if (string.IsNullOrWhiteSpace(label))
                    {
                        label = ScrudLocalizationHelper.GetResourceString(resourceClassName, columnName);
                    }

                    if (!string.IsNullOrWhiteSpace(defaultValue))
                    {
                        if (!defaultValue.StartsWith("nextVal", StringComparison.OrdinalIgnoreCase))
                        {
                            textBox.Text = defaultValue;
                        }
                    }

                    textBox.ReadOnly = disabled;

                    if (isSerial)
                    {
                        textBox.ReadOnly = true;
                    }
                    else
                    {
                        if (!isNullable)
                        {
                            using (
                                RequiredFieldValidator required = ScrudFactoryHelper.GetRequiredFieldValidator(textBox,
                                                                                                               errorCssClass))
                            {
                                ScrudFactoryHelper.AddRow(htmlTable, label + Labels.RequiredFieldIndicator, textBox,
                                                          numberValidator, required);
                                return;
                            }
                        }
                    }

                    ScrudFactoryHelper.AddRow(htmlTable, label, textBox, numberValidator);
                }
            }
        }
Example #31
0
    private void LoadGMCommandTemplate()
    {
        int textBoxCount = 100;
        int validatorCount = 100;
        
        TableCell templateTableCell = this.TemplateTable.FindControl("TemplateTableCell") as TableCell;

        XPathNavigator nav;
        XPathDocument docNav;

        docNav = new XPathDocument(WebConfig.WebsiteRootPath + "GMCommandTemplate.xml");
        nav = docNav.CreateNavigator();
        nav.MoveToRoot();
        nav.MoveToFirstChild();

        while (nav.NodeType != XPathNodeType.Element)
            nav.MoveToNext();

        if (nav.LocalName != "GMCommandTemplates")
            throw new Exception("根结点必须为&lt;GMCommandTemplates&gt;");

        if (nav.HasChildren)
            nav.MoveToFirstChild();
        else
            throw new Exception("&lt;GMCommandTemplates&gt;下必须有子结点");

        do
        {
            if (nav.NodeType == XPathNodeType.Element)
            {
                if (nav.LocalName != "Template")
                    throw new Exception("&lt;GMCommandTemplates&gt;下的子结点只允许为&lt;Template&gt;");

                if (nav.HasChildren)
                {
                    nav.MoveToFirstChild();

                    GMCommandTemplate template = new GMCommandTemplate();

                    Panel panel = new Panel();
                    Table table = new Table();

                    string templateName = String.Empty;
                    string cmd = String.Empty;
                    
                    Label desLabel = new Label();                    
                    panel.Controls.Add(desLabel);

                    do
                    {
                        if (nav.LocalName == "TemplateName")
                        {
                            templateName = nav.Value;
                            if (IsPostBack == false)
                                ListBoxOperation.Items.Add(new ListItem(templateName));
                        }
                        else if (nav.LocalName == "Executer")
                        {
                            if ((nav.Value == "Role") || (nav.Value == "Account"))
                            {
                                TableRow row = new TableRow();
                                row.HorizontalAlign = HorizontalAlign.Center;
                                TableCell[] cell = new TableCell[2];
                                for (int i = 0; i < 2; i++)
                                    cell[i] = new TableCell();

                                cell[0].Width = new Unit(20f, UnitType.Percentage);
                                cell[0].Style.Value = "text-align: center;font-weight: bold;color: #FFFFFF;background-color: #5099B3;height: 20px;border-bottom: solid 1px #808080;border-right: solid 1px #808080;";

                                //Role和Account唯一不同的地方
                                if (nav.Value == "Role")
                                {
                                    cell[0].Text = "角色名";
                                    template.isAccountName = false;
                                }
                                else
                                {
                                    cell[0].Text = "账号名";
                                    template.isAccountName = true;
                                }

                                cell[1].Width = new Unit(80f, UnitType.Percentage);

                                TextBox textBox = new TextBox();
                                textBox.ID = "textBox" + textBoxCount.ToString();
                                textBoxCount++;
                                cell[1].Controls.Add(textBox);
                                template.PlayerNameTextBox = textBox;

                                //必须有输入,RequiredFieldValidator
                                RequiredFieldValidator validator = new RequiredFieldValidator();
                                validator.ID = "validator" + validatorCount.ToString();
                                validatorCount++;
                                validator.ControlToValidate = textBox.ID;
                                validator.Display = ValidatorDisplay.None;
                                validator.ErrorMessage = StringDef.RequiredFieldValidatorErrorMsg;
                                validator.SetFocusOnError = true;
                                cell[1].Controls.Add(validator);
                                AjaxControlToolkit.ValidatorCalloutExtender validatorExtender = new AjaxControlToolkit.ValidatorCalloutExtender();
                                validatorExtender.TargetControlID = validator.ID;
                                cell[1].Controls.Add(validatorExtender);

                                row.Cells.AddRange(cell);
                                table.Rows.Add(row);
                            }
                            else if (nav.Value == "GameCenter")
                            {
                                //不生成任何控件,什么也不做,只是保证"GameCenter"为合法的值
                            }
                            else
                                throw new Exception("&lt;Executer&gt;的值" + nav.Value + "不合法,合法的值为Role,Account或GameCenter");
                        }
                        else if (nav.LocalName == "TemplateCMD")
                        {
                            cmd = nav.Value;
                        }
                        else if (nav.LocalName == "Description")
                        {
                            desLabel.Text = nav.Value + "<br />&nbsp;";
                        }
                        else if (nav.LocalName == "Parameter")
                        {
                            if (nav.HasChildren)
                            {
                                nav.MoveToFirstChild();

                                if (nav.LocalName == "Name")
                                {
                                    TableRow row = new TableRow();
                                    row.HorizontalAlign = HorizontalAlign.Center;
                                    TableCell[] cell = new TableCell[2];
                                    for (int i = 0; i < 2; i++)
                                        cell[i] = new TableCell();

                                    cell[0].Width = new Unit(20f, UnitType.Percentage);
                                    cell[0].Style.Value = "text-align: center;font-weight: bold;color: #FFFFFF;background-color: #5099B3;height: 20px;border-bottom: solid 1px #808080;border-right: solid 1px #808080;";
                                    cell[0].Text = nav.Value;
                                    cell[1].Width = new Unit(80f, UnitType.Percentage);

                                    if (nav.MoveToNext())
                                    {
                                        if (nav.LocalName == "Control")
                                        {
                                            if (nav.HasChildren)
                                            {
                                                nav.MoveToFirstChild();

                                                if (nav.LocalName == "Type")
                                                {
                                                    switch (nav.Value)
                                                    {
                                                        case "TextBox":
                                                            TextBox textBox = new TextBox();
                                                            textBox.ID = "textBox" + textBoxCount.ToString();
                                                            textBoxCount++;
                                                            cell[1].Controls.Add(textBox);
                                                            template.ControlList.Add(textBox);

                                                            //必须有输入,RequiredFieldValidator
                                                            RequiredFieldValidator validator = new RequiredFieldValidator();
                                                            validator.ID = "validator" + validatorCount.ToString();
                                                            validatorCount++;
                                                            validator.ControlToValidate = textBox.ID;
                                                            validator.Display = ValidatorDisplay.None;
                                                            validator.ErrorMessage = StringDef.RequiredFieldValidatorErrorMsg;
                                                            validator.SetFocusOnError = true;
                                                            cell[1].Controls.Add(validator);
                                                            AjaxControlToolkit.ValidatorCalloutExtender validatorExtender = new AjaxControlToolkit.ValidatorCalloutExtender();
                                                            validatorExtender.TargetControlID = validator.ID;
                                                            cell[1].Controls.Add(validatorExtender);

                                                            //TextBox类型可能有的其他特性定义
                                                            while (nav.MoveToNext())
                                                            {
                                                                if (nav.LocalName == "MultiLine")
                                                                {
                                                                    if (nav.Value == "True")
                                                                    {
                                                                        textBox.TextMode = TextBoxMode.MultiLine;
                                                                        textBox.Wrap = true;
                                                                    }
                                                                }
                                                                else if (nav.LocalName == "MaxCharCount")
                                                                {
                                                                    if (textBox.TextMode == TextBoxMode.MultiLine)
                                                                    {
                                                                        textBox.Attributes.Add("onkeypress", "return validateMaxLength(this, " + nav.Value + ");");
                                                                        textBox.Attributes.Add("onbeforepaste", "doBeforePaste(this, " + nav.Value + ");");
                                                                        textBox.Attributes.Add("onpaste", "doPaste(this, " + nav.Value + ");");
                                                                    }
                                                                    else
                                                                        textBox.MaxLength = int.Parse(nav.Value);
                                                                }
                                                                else if (nav.LocalName == "Style")
                                                                    textBox.Style.Value = nav.Value;
                                                            }
                                                            break;

                                                        case "IntegerTextBox":
                                                            TextBox integerTextBox = new TextBox();
                                                            integerTextBox.ID = "textBox" + textBoxCount.ToString();
                                                            textBoxCount++;
                                                            cell[1].Controls.Add(integerTextBox);
                                                            template.ControlList.Add(integerTextBox);

                                                            //必须有输入,RequiredFieldValidator
                                                            RequiredFieldValidator integerValidator = new RequiredFieldValidator();
                                                            integerValidator.ID = "validator" + validatorCount.ToString();
                                                            validatorCount++;
                                                            integerValidator.ControlToValidate = integerTextBox.ID;
                                                            integerValidator.Display = ValidatorDisplay.None;
                                                            integerValidator.ErrorMessage = StringDef.RequiredFieldValidatorErrorMsg;
                                                            integerValidator.SetFocusOnError = true;
                                                            cell[1].Controls.Add(integerValidator);
                                                            AjaxControlToolkit.ValidatorCalloutExtender integerValidatorExtender = new AjaxControlToolkit.ValidatorCalloutExtender();
                                                            integerValidatorExtender.TargetControlID = integerValidator.ID;
                                                            cell[1].Controls.Add(integerValidatorExtender);

                                                            //IntegerTextBox类型,用CompareValidator限定只能输入整数,
                                                            CompareValidator compareValidator = new CompareValidator();
                                                            compareValidator.ID = "validator" + validatorCount.ToString();
                                                            validatorCount++;
                                                            compareValidator.ControlToValidate = integerTextBox.ID;
                                                            compareValidator.Display = ValidatorDisplay.None;
                                                            compareValidator.ErrorMessage = "必须填写整数";
                                                            compareValidator.SetFocusOnError = true;
                                                            compareValidator.Operator = ValidationCompareOperator.DataTypeCheck;
                                                            compareValidator.Type = ValidationDataType.Integer;
                                                            cell[1].Controls.Add(compareValidator);
                                                            AjaxControlToolkit.ValidatorCalloutExtender compareValidatorExtender = new AjaxControlToolkit.ValidatorCalloutExtender();
                                                            compareValidatorExtender.TargetControlID = compareValidator.ID;
                                                            cell[1].Controls.Add(compareValidatorExtender);

                                                            //IntegerTextBox类型可能有的其他特性定义
                                                            while (nav.MoveToNext())
                                                            {
                                                                //用CompareValidator限定值必须大于等于MinValue
                                                                if (nav.LocalName == "MinValue")
                                                                {
                                                                    string minValue = nav.Value;

                                                                    CompareValidator minValidator = new CompareValidator();
                                                                    minValidator.ID = "validator" + validatorCount.ToString();
                                                                    validatorCount++;
                                                                    minValidator.ControlToValidate = integerTextBox.ID;
                                                                    minValidator.Display = ValidatorDisplay.None;
                                                                    minValidator.ErrorMessage = "输入的值必须大于等于" + minValue;
                                                                    minValidator.SetFocusOnError = true;
                                                                    minValidator.Operator = ValidationCompareOperator.GreaterThanEqual;
                                                                    minValidator.Type = ValidationDataType.Integer;
                                                                    minValidator.ValueToCompare = minValue;
                                                                    cell[1].Controls.Add(minValidator);
                                                                    AjaxControlToolkit.ValidatorCalloutExtender minValidatorExtender = new AjaxControlToolkit.ValidatorCalloutExtender();
                                                                    minValidatorExtender.TargetControlID = minValidator.ID;
                                                                    cell[1].Controls.Add(minValidatorExtender);
                                                                }

                                                                //用CompareValidator限定值必须小于等于MaxValue
                                                                else if (nav.LocalName == "MaxValue")
                                                                {
                                                                    string maxValue = nav.Value;

                                                                    CompareValidator maxValidator = new CompareValidator();
                                                                    maxValidator.ID = "validator" + validatorCount.ToString();
                                                                    validatorCount++;
                                                                    maxValidator.ControlToValidate = integerTextBox.ID;
                                                                    maxValidator.Display = ValidatorDisplay.None;
                                                                    maxValidator.ErrorMessage = "输入的值必须小于等于" + maxValue;
                                                                    maxValidator.SetFocusOnError = true;
                                                                    maxValidator.Operator = ValidationCompareOperator.LessThanEqual;
                                                                    maxValidator.Type = ValidationDataType.Integer;
                                                                    maxValidator.ValueToCompare = maxValue;
                                                                    cell[1].Controls.Add(maxValidator);
                                                                    AjaxControlToolkit.ValidatorCalloutExtender maxValidatorExtender = new AjaxControlToolkit.ValidatorCalloutExtender();
                                                                    maxValidatorExtender.TargetControlID = maxValidator.ID;
                                                                    cell[1].Controls.Add(maxValidatorExtender);
                                                                }
                                                                else if (nav.LocalName == "Style")
                                                                    integerTextBox.Style.Value = nav.Value;
                                                            }
                                                            break;

                                                        case "DropDownList":
                                                            DropDownList dropDownList = new DropDownList();
                                                            cell[1].Controls.Add(dropDownList);
                                                            template.ControlList.Add(dropDownList);

                                                            while (nav.MoveToNext())
                                                            {
                                                                if (nav.LocalName == "Style")
                                                                    dropDownList.Style.Value = nav.Value;

                                                                //添加dropDownList具有的Item
                                                                else if (nav.LocalName == "Item")
                                                                {
                                                                    if (nav.HasChildren)
                                                                    {
                                                                        nav.MoveToFirstChild();

                                                                        ListItem item = new ListItem();

                                                                        do
                                                                        {
                                                                            if (nav.LocalName == "Text")
                                                                                item.Text = nav.Value;
                                                                            else if (nav.LocalName == "Value")
                                                                                item.Value = nav.Value;
                                                                        }
                                                                        while (nav.MoveToNext());

                                                                        if ((item.Text != String.Empty) && (item.Value != String.Empty))
                                                                            dropDownList.Items.Add(item);

                                                                        nav.MoveToParent();
                                                                    }
                                                                }
                                                            }
                                                            break;

                                                        default:
                                                            throw new Exception("&lt;Type&gt;的值" + nav.Value + "不合法,合法的值为TextBox,IntegerTextBox或DropDownList");
                                                    }
                                                }

                                                nav.MoveToParent();
                                            }
                                            else
                                                throw new Exception("&lt;Control&gt;下必须有子结点");
                                        }
                                        else
                                            throw new Exception("&lt;Name&gt;后的结点只能为&lt;Control&gt;");
                                    }
                                    else
                                        throw new Exception("&lt;Parameter&gt;下不能只有&lt;Name&gt;结点");

                                    row.Cells.AddRange(cell);
                                    table.Rows.Add(row);
                                }
                                else
                                    throw new Exception("&lt;Parameter&gt;下的第一个结点必须为&lt;Name&gt;");

                                nav.MoveToParent();
                            }
                            else
                                throw new Exception("&lt;Parameter&gt;下必须有子结点");
                        }
                        else
                            throw new Exception("结点&lt;" + nav.LocalName + "&gt;不合法");
                    }
                    while (nav.MoveToNext());

                    panel.Controls.Add(table);

                    Button button = new Button();
                    button.Text = templateName;
                    button.CommandName = templateList.Count.ToString();
                    button.Click += new EventHandler(Button_Click);
                    button.OnClientClick = "if (Page_ClientValidate()){return window.confirm('确认执行GM指令吗?');}";
                    panel.Controls.Add(button);

                    templateTableCell.Controls.Add(panel);

                    template.TemplatePanel = panel;
                    template.cmd = cmd;

                    templateList.Add(template);

                    nav.MoveToParent();
                }
                else
                    throw new Exception("&lt;Template&gt;下必须有子结点");                
            }            
        }
        while (nav.MoveToNext());

        if (IsPostBack == false)
            ListBoxOperation.SelectedIndex = 0;

        SetPanelVisible();    
    }
Example #32
0
        /// <summary>
        /// Init the components of the panel through the special pageid
        /// </summary>
        private void InitComponents()
        {
            Hashtable _htDataObjectdControlsInfo = new Hashtable();
            HtmlTable T_Content = new HtmlTable();

            T_Content.CellPadding = 0;
            T_Content.CellSpacing = 0;
            T_Content.Width       = "100%";
            T_Content.Border      = 0;
            T_Content.ID          = "T_Content_" + ID;
            this.Controls.Add(T_Content);

            HtmlTableRow  T_tr_title = new HtmlTableRow();
            HtmlTableCell T_tc_title = new HtmlTableCell();

            T_tr_title.Cells.Add(T_tc_title);
            T_Content.Rows.Add(T_tr_title);

            #region The title of the panel
            HtmlTable tb_title = new HtmlTable();
            T_tc_title.Controls.Add(tb_title);
            tb_title.CellPadding         = 0;
            tb_title.CellSpacing         = 0;
            tb_title.Width               = "100%";
            tb_title.Height              = "30px";
            tb_title.Border              = 0;
            tb_title.Attributes["class"] = "h3Row";

            HtmlTableRow  tr_title = new HtmlTableRow();
            HtmlTableCell tc_title = new HtmlTableCell();
            tr_title.Cells.Add(tc_title);
            tb_title.Rows.Add(tr_title);
            tc_title.InnerHtml = "<h3>工作流提交的数据字段内容</h3>";
            #endregion

            #region The content of the panel
            HtmlTableRow T_tr_panelcontent = new HtmlTableRow();
            T_tr_panelcontent.ID = "T_tr_panelcontent";
            HtmlTableCell T_tc_panelcontent = new HtmlTableCell();
            T_tr_panelcontent.Cells.Add(T_tc_panelcontent);
            T_Content.Rows.Add(T_tr_panelcontent);


            HtmlTable tb_panel_content = new HtmlTable();
            tb_panel_content.Width = "100%";
            tb_panel_content.Attributes["class"] = "tabForm";
            T_tc_panelcontent.Controls.Add(tb_panel_content);
            IList <EWF_Flow_DataObject> _dataobjects = new EWF_Flow_AppBLL(App).GetDataObjectList();
            int i = 0;
            foreach (EWF_Flow_DataObject _dataobject in _dataobjects)
            {
                if (_dataobject.Visible == "N")
                {
                    continue;
                }

                #region 判断该控件是否已存在
                if (_htDataObjectdControlsInfo.Contains(_dataobject.Name))
                {
                    continue;
                }
                #endregion

                #region 判断是否要增加新行
                HtmlTableRow tr_panel_detail;
                if (i >= FieldCount || i == 0)
                {
                    tr_panel_detail = new HtmlTableRow();
                    tb_panel_content.Rows.Add(tr_panel_detail);
                    i = 0;
                }
                else
                {
                    tr_panel_detail = tb_panel_content.Rows[tb_panel_content.Rows.Count - 1];
                }
                #endregion

                #region 增加Label Cell
                HtmlTableCell tc_displayname = new HtmlTableCell();
                tc_displayname.Attributes["Class"]  = "dataLabel";
                tc_displayname.Attributes["Style"]  = "width: 80px; height: 18px;";
                tc_displayname.Attributes["nowrap"] = "nowrap";
                tc_displayname.InnerText            = _dataobject.DisplayName;
                tr_panel_detail.Cells.Add(tc_displayname);
                #endregion

                #region 增加Field Cell
                HtmlTableCell tc_control = new HtmlTableCell();
                tc_control.Attributes["Class"] = "dataField";

                if (_dataobject.ColSpan > 0)
                {
                    if (i + _dataobject.ColSpan <= FieldCount)
                    {
                        tc_control.ColSpan = 2 * _dataobject.ColSpan - 1;
                        i = i + _dataobject.ColSpan;
                    }
                    else
                    {
                        tc_control.ColSpan = 2 * (FieldCount - i) - 1;
                        i = 0;
                    }
                }
                else
                {
                    i++;
                }

                WebControl control = null;

                int    RelationType       = _dataobject.RelationType;
                string RelationTableName  = _dataobject.RelationTableName;
                string RelationValueField = _dataobject.RelationValueField;
                string RelationTextField  = _dataobject.RelationTextField;

                #region 根据控件类型生成相应的控件
                switch (_dataobject.ControlType)
                {
                case 1:    //Label
                    control = new Label();
                    break;

                case 2:    //TextBox
                    control = new TextBox();
                    if (_dataobject.DataType == 4)
                    {
                        control.Attributes["onfocus"] = "setday(this);";
                    }
                    break;

                case 3:                    //DropDownList
                    control = new DropDownList();
                    if (RelationType == 1) //Relation to the dictionary
                    {
                        ((DropDownList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true);
                    }
                    else if (RelationType == 2)    //Relation to the model table
                    {
                        ((DropDownList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField);
                    }
                    else
                    {
                        break;
                    }

                    ((DropDownList)control).DataTextField  = "Value";
                    ((DropDownList)control).DataValueField = "Key";
                    ((DropDownList)control).DataBind();
                    ((DropDownList)control).Items.Insert(0, new ListItem("请选择...", "0"));
                    break;

                case 4:                    //RadioButtonList
                    control = new RadioButtonList();
                    if (RelationType == 1) //Relation to the dictionary
                    {
                        ((RadioButtonList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true);
                    }
                    else if (RelationType == 2)    //Relation to the model table
                    {
                        ((RadioButtonList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField);
                    }
                    else
                    {
                        break;
                    }

                    ((RadioButtonList)control).RepeatColumns   = 6;
                    ((RadioButtonList)control).RepeatDirection = RepeatDirection.Horizontal;
                    ((RadioButtonList)control).DataTextField   = "Value";
                    ((RadioButtonList)control).DataValueField  = "Key";
                    ((RadioButtonList)control).DataBind();
                    if (((RadioButtonList)control).Items.Count != 0)
                    {
                        ((RadioButtonList)control).SelectedIndex = 0;
                    }
                    break;

                case 5:    //MutiLinesTextBox
                    control = new TextBox();
                    ((TextBox)control).TextMode = TextBoxMode.MultiLine;
                    if (_dataobject.ControlHeight > 0)
                    {
                        ((TextBox)control).Height = new Unit(_dataobject.ControlHeight);
                    }
                    break;

                case 6:    //TextBox supports search
                    control    = new MCSSelectControl();
                    control.ID = "C_" + _dataobject.Name.ToString();
                    if (RelationType == 2)    //Relation to the model table
                    {
                        ((MCSSelectControl)control).PageUrl = _dataobject.SearchPageURL;
                    }
                    break;

                case 7:    //MCSTreeControl

                    control = new MCSTreeControl();


                    if (RelationType == 2)                               //Relation to the model table
                    {
                        control.ID = "C_" + _dataobject.Name.ToString(); //在设置控件DataSource之前,必须要有ID属性 Shen Gang 20090110
                        if (_dataobject.RelationTableName == "MCS_SYS.dbo.Addr_OrganizeCity")
                        {
                            #region 如果为管理片区字段,则取员工所能管辖的片区
                            Org_StaffBLL staff = new Org_StaffBLL((int)System.Web.HttpContext.Current.Session["UserID"]);
                            ((MCSTreeControl)control).DataSource       = staff.GetStaffOrganizeCity();
                            ((MCSTreeControl)control).IDColumnName     = "ID";
                            ((MCSTreeControl)control).NameColumnName   = "Name";
                            ((MCSTreeControl)control).ParentColumnName = "SuperID";

                            if (((MCSTreeControl)control).DataSource.Select("ID = 1").Length > 0 || staff.Model.OrganizeCity == 0)
                            {
                                ((MCSTreeControl)control).RootValue = "0";
                                if (!Page.IsPostBack)
                                {
                                    ((MCSTreeControl)control).SelectValue = "0";
                                }
                            }
                            else
                            {
                                ((MCSTreeControl)control).RootValue = new Addr_OrganizeCityBLL(staff.Model.OrganizeCity).Model.SuperID.ToString();
                                if (!Page.IsPostBack)
                                {
                                    ((MCSTreeControl)control).SelectValue = staff.Model.OrganizeCity.ToString();
                                }
                            }

                            #endregion
                        }
                        else
                        {
                            ((MCSTreeControl)control).TableName        = RelationTableName;
                            ((MCSTreeControl)control).IDColumnName     = RelationValueField;
                            ((MCSTreeControl)control).NameColumnName   = RelationTextField;
                            ((MCSTreeControl)control).ParentColumnName = "SuperID";
                        }
                    }
                    break;
                }
                #endregion

                control.ID      = "C_" + _dataobject.Name.ToString();
                control.Enabled = _dataobject.Enable.ToUpper() == "Y";
                control.ToolTip = _dataobject.Description;
                if (_dataobject.ControlWidth > 0)
                {
                    control.Width = _dataobject.ControlWidth;
                }

                tc_control.Controls.Add(control);

                #region 如果是文本框时,加上输入验证控件
                if (_dataobject.IsRequireField == "Y")
                {
                    Label lbl_reqinfo = new Label();
                    lbl_reqinfo.Text      = "*";
                    lbl_reqinfo.ForeColor = System.Drawing.Color.Red;
                    tc_control.Controls.Add(lbl_reqinfo);
                }
                //add validate control for the textbox

                if (_dataobject.ControlType == 2 || _dataobject.ControlType == 5)
                {
                    RequiredFieldValidator     _requiredfieldvalidator     = null;
                    CompareValidator           _comparevalidator           = null;
                    RegularExpressionValidator _regularexpressionvalidator = null;
                    if (_dataobject.IsRequireField == "Y")
                    {
                        _requiredfieldvalidator = new RequiredFieldValidator();
                        _requiredfieldvalidator.ControlToValidate = control.ID;
                        _requiredfieldvalidator.Display           = ValidatorDisplay.Dynamic;
                        _requiredfieldvalidator.ErrorMessage      = "必填";
                        _requiredfieldvalidator.ForeColor         = System.Drawing.Color.Red;
                        _requiredfieldvalidator.ValidationGroup   = _validationgroup;

                        tc_control.Controls.Add(_requiredfieldvalidator);
                    }

                    if (_dataobject.DataType == 1 || _dataobject.DataType == 2 || _dataobject.DataType == 4)        //非varchar 字符串
                    {
                        _comparevalidator = new CompareValidator();
                        _comparevalidator.ControlToValidate = control.ID;
                        _comparevalidator.Operator          = ValidationCompareOperator.DataTypeCheck;
                        _comparevalidator.Display           = ValidatorDisplay.Dynamic;
                        _comparevalidator.ForeColor         = System.Drawing.Color.Red;
                        _comparevalidator.ValidationGroup   = _validationgroup;

                        if (_dataobject.DataType == 1)//int
                        {
                            _comparevalidator.Type         = ValidationDataType.Integer;
                            _comparevalidator.ErrorMessage = "应为整数";
                        }
                        if (_dataobject.DataType == 2)//decimal
                        {
                            _comparevalidator.Type         = ValidationDataType.Double;
                            _comparevalidator.ErrorMessage = "应为数字";
                        }
                        if (_dataobject.DataType == 4)//datetime
                        {
                            _comparevalidator.Type         = ValidationDataType.Date;
                            _comparevalidator.ErrorMessage = "日期格式不正确";
                        }
                        tc_control.Controls.Add(_comparevalidator);
                    }
                    else
                    {
                        if (_dataobject.RegularExpression != "")
                        {
                            _regularexpressionvalidator = new RegularExpressionValidator();
                            _regularexpressionvalidator.ControlToValidate    = control.ID;
                            _regularexpressionvalidator.ErrorMessage         = "数据格式不正确";
                            _regularexpressionvalidator.ForeColor            = System.Drawing.Color.Red;
                            _regularexpressionvalidator.ValidationExpression = _dataobject.RegularExpression;
                            _regularexpressionvalidator.ValidationGroup      = ValidationGroup;
                            _regularexpressionvalidator.Display = ValidatorDisplay.Dynamic;
                            tc_control.Controls.Add(_regularexpressionvalidator);
                        }
                    }
                }
                #endregion

                tr_panel_detail.Cells.Add(tc_control);
                #endregion

                #region Record the info of the control created
                DataObjectControlInfo dataobjectcontrolinfo = new DataObjectControlInfo();

                dataobjectcontrolinfo.ControlName    = control.ID;
                dataobjectcontrolinfo.ControlType    = _dataobject.ControlType;
                dataobjectcontrolinfo.DataObjectID   = _dataobject.ID;
                dataobjectcontrolinfo.DataObjectName = _dataobject.Name;
                _htDataObjectdControlsInfo.Add(dataobjectcontrolinfo.DataObjectName, dataobjectcontrolinfo);
                #endregion
            }
            #endregion

            ViewState["HTDataObjectControlInfo"] = _htDataObjectdControlsInfo;

            if (new EWF_Flow_AppBLL(App).Model.RelateBusiness.ToUpper() == "Y")
            {
                SetPanelEnable(false);
            }
        }
        /// <summary>
        /// Override this method with code to set the validationgroup for all applicable form elements of the child control.
        /// </summary>
        public void SetFormFieldValidationGroup(string validationGroup)
        {
            if (string.IsNullOrWhiteSpace(this.ValidationGroup))
            {
                this.ValidationGroup = validationGroup;
            }

            List <WebControl> ctrls = RecursiveFindWebControls(this.Controls.OfType <WebControl>().ToList());

            foreach (WebControl ctrl in ctrls)
            {
                if (ctrl is ValidationSummary)
                {
                    ((ValidationSummary)ctrl).ValidationGroup = this.ValidationGroup;
                }
                else if (ctrl is RequiredFieldValidator)
                {
                    RequiredFieldValidator rfv = (RequiredFieldValidator)ctrl;
                    rfv.ValidationGroup = this.ValidationGroup;

                    if (!string.IsNullOrWhiteSpace(ValidationMessagePrefix))
                    {
                        rfv.ErrorMessage = ValidationMessagePrefix + rfv.ErrorMessage;
                    }
                }
                else if (ctrl is CompareValidator)
                {
                    CompareValidator cpv = (CompareValidator)ctrl;
                    cpv.ValidationGroup = this.ValidationGroup;

                    if (!string.IsNullOrWhiteSpace(ValidationMessagePrefix))
                    {
                        cpv.ErrorMessage = ValidationMessagePrefix + cpv.ErrorMessage;
                    }
                }
                else if (ctrl is CustomValidator)
                {
                    CustomValidator cst = (CustomValidator)ctrl;
                    cst.ValidationGroup = this.ValidationGroup;

                    if (!string.IsNullOrWhiteSpace(ValidationMessagePrefix))
                    {
                        cst.ErrorMessage = ValidationMessagePrefix + cst.ErrorMessage;
                    }
                }
                else if (ctrl is RegularExpressionValidator)
                {
                    RegularExpressionValidator rev = (RegularExpressionValidator)ctrl;
                    rev.ValidationGroup = this.ValidationGroup;

                    if (!string.IsNullOrWhiteSpace(ValidationMessagePrefix))
                    {
                        rev.ErrorMessage = ValidationMessagePrefix + rev.ErrorMessage;
                    }
                }
                else if (ctrl is RangeValidator)
                {
                    RangeValidator rng = (RangeValidator)ctrl;
                    rng.ValidationGroup = this.ValidationGroup;

                    if (!string.IsNullOrWhiteSpace(ValidationMessagePrefix))
                    {
                        rng.ErrorMessage = ValidationMessagePrefix + rng.ErrorMessage;
                    }
                }
                else if (ctrl is TextBox)
                {
                    TextBox txt = ((TextBox)ctrl);
                    txt.ValidationGroup = this.ValidationGroup;
                }
                else if (ctrl is DropDownList)
                {
                    ((DropDownList)ctrl).ValidationGroup = this.ValidationGroup;
                }
                else if (ctrl is Button)
                {
                    Button btn = ((Button)ctrl);
                    btn.ValidationGroup = this.ValidationGroup;
                }
                else if (ctrl is CheckBoxList)
                {
                    CheckBoxList cbl = ((CheckBoxList)ctrl);
                    cbl.ValidationGroup = this.ValidationGroup;
                }
                else if (ctrl is RadioButtonList)
                {
                    RadioButtonList cbl = ((RadioButtonList)ctrl);
                    cbl.ValidationGroup = this.ValidationGroup;
                }
                else /* and so on.....*/ } {
                // need to add the various field validators and other common control types - RC
        }
    }
Example #34
0
        public Control GetWebControl(System.Web.HttpServerUtility server, XmlNode renderingDocument)
        {
            PlaceHolder ph = new PlaceHolder();

            Label lbl = new Label();

            if (renderingDocument.Attributes["label"] != null)
            {
                lbl.Text = renderingDocument.Attributes["renderedLabel"].Value.FromXmlValue2Render(server);
            }
            else
            {
                lbl.Text = this.Name.FromXmlName2Render(server);
            }
            lbl.CssClass = "label";
            ph.Controls.Add(lbl);

            VEMapControl vem = new VEMapControl(this);

            if (renderingDocument.Attributes["class"] != null)
            {
                vem.CssClass = renderingDocument.Attributes["class"].Value.FromXmlValue2Render(server);
            }
            if (renderingDocument.Attributes["rel"] != null)
            {
                renderingDocument.Attributes["rel"].Value.FromXmlValue2Render(server);
            }
            if (renderingDocument.Attributes["description"] != null)
            {
                vem.ToolTip = renderingDocument.Attributes["description"].Value.FromXmlValue2Render(server);
            }

            ph.Controls.Add(vem);

            // Validators

            List <XmlSchemaElement> baseSchemaElements = Common.getElementsFromSchema(baseSchema);

            if (!baseSchemaElements[0].IsNillable)
            {
                RequiredFieldValidator rqfv = new RequiredFieldValidator();
                rqfv.ErrorMessage      = "Required fields shouldn't be empty";
                rqfv.ControlToValidate = vem.ID + "$latitude";
                rqfv.ValidationGroup   = "1";
                rqfv.Display           = ValidatorDisplay.Dynamic;
                ph.Controls.Add(rqfv);
            }
            if (!baseSchemaElements[1].IsNillable)
            {
                RequiredFieldValidator rqfv = new RequiredFieldValidator();
                rqfv.ErrorMessage      = "Required fields shouldn't be empty";
                rqfv.ControlToValidate = vem.ID + "$longitude";
                rqfv.Display           = ValidatorDisplay.Dynamic;
                ph.Controls.Add(rqfv);
                rqfv.ValidationGroup = "1";
            }

            // Setting up base validators
            // ( validators for min and max of latitude (-90,90) and longitude (-180,180) )

            CompareValidator maxLatitudeValidator = new CompareValidator();

            maxLatitudeValidator.ID = this.Name + "_maxLatitudeValidator";
            maxLatitudeValidator.ControlToValidate = vem.ID + "$latitude";;
            maxLatitudeValidator.Type            = ValidationDataType.Integer;
            maxLatitudeValidator.ValueToCompare  = "90";
            maxLatitudeValidator.Operator        = ValidationCompareOperator.LessThanEqual;
            maxLatitudeValidator.ErrorMessage    = "The value has to be lower than or equal to 90";
            maxLatitudeValidator.Text            = maxLatitudeValidator.ErrorMessage;
            maxLatitudeValidator.Display         = ValidatorDisplay.Dynamic;
            maxLatitudeValidator.Type            = ValidationDataType.Double;
            maxLatitudeValidator.ValidationGroup = "1";

            ph.Controls.Add(maxLatitudeValidator);

            CompareValidator minLatitudeValidator = new CompareValidator();

            minLatitudeValidator.ID = this.Name + "_minLatitudeValidator";
            minLatitudeValidator.ControlToValidate = vem.ID + "$latitude";;
            minLatitudeValidator.Type            = ValidationDataType.Integer;
            minLatitudeValidator.ValueToCompare  = "-90";
            minLatitudeValidator.Operator        = ValidationCompareOperator.GreaterThanEqual;
            minLatitudeValidator.ErrorMessage    = "The value has to be greater than or equal to -90";
            minLatitudeValidator.Text            = minLatitudeValidator.ErrorMessage;
            minLatitudeValidator.Display         = ValidatorDisplay.Dynamic;
            minLatitudeValidator.Type            = ValidationDataType.Double;
            minLatitudeValidator.ValidationGroup = "1";
            ph.Controls.Add(minLatitudeValidator);

            CompareValidator maxLongitudeValidator = new CompareValidator();

            maxLongitudeValidator.ID = this.Name + "_maxLongitudeValidator";
            maxLongitudeValidator.ControlToValidate = vem.ID + "$longitude";;
            maxLongitudeValidator.Type            = ValidationDataType.Integer;
            maxLongitudeValidator.ValueToCompare  = "180";
            maxLongitudeValidator.Operator        = ValidationCompareOperator.LessThanEqual;
            maxLongitudeValidator.ErrorMessage    = "The value has to be lower than or equal to 180";
            maxLongitudeValidator.Text            = maxLongitudeValidator.ErrorMessage;
            maxLongitudeValidator.Display         = ValidatorDisplay.Dynamic;
            maxLongitudeValidator.Type            = ValidationDataType.Double;
            maxLongitudeValidator.ValidationGroup = "1";
            ph.Controls.Add(maxLongitudeValidator);

            CompareValidator minLongitudeValidator = new CompareValidator();

            minLongitudeValidator.ID = this.Name + "_minLongitudeValidator";
            minLongitudeValidator.ControlToValidate = vem.ID + "$longitude";;
            minLongitudeValidator.Type            = ValidationDataType.Integer;
            minLongitudeValidator.ValueToCompare  = "-180";
            minLongitudeValidator.Operator        = ValidationCompareOperator.GreaterThanEqual;
            minLongitudeValidator.ErrorMessage    = "The value has to be greater than or equal to -180";
            minLongitudeValidator.Text            = minLongitudeValidator.ErrorMessage;
            minLongitudeValidator.Display         = ValidatorDisplay.Dynamic;
            minLongitudeValidator.Type            = ValidationDataType.Double;
            minLongitudeValidator.ValidationGroup = "1";
            ph.Controls.Add(minLongitudeValidator);

            // setting up latitude constraints
            if (((XmlSchemaSimpleType)baseSchemaElements[0].SchemaType) != null)
            {
                XmlSchemaObjectCollection latConstrColl =
                    ((XmlSchemaSimpleTypeRestriction)
                     ((XmlSchemaSimpleType)
                      baseSchemaElements[0]
                      .SchemaType).Content).Facets;

                foreach (XmlSchemaFacet facet in latConstrColl)
                {
                    // TODO
                    // No Contraints yet :D
                }
            }

            // setting up longitude constraints
            if (((XmlSchemaSimpleType)baseSchemaElements[1].SchemaType) != null)
            {
                XmlSchemaObjectCollection longConstrColl =
                    ((XmlSchemaSimpleTypeRestriction)
                     ((XmlSchemaSimpleType)
                      baseSchemaElements[1]
                      .SchemaType).Content).Facets;

                foreach (XmlSchemaFacet facet in longConstrColl)
                {
                    // TODO
                    // No Contraints yet :D
                }
            }

            // setting up custom constraints (close your eyes =)
            XmlSchemaComplexContentExtension cce = (XmlSchemaComplexContentExtension)((XmlSchemaComplexContent)(((XmlSchemaComplexType)baseSchema.Items[0])).ContentModel).Content;

            if (cce.Annotation != null)
            {
                foreach (XmlSchemaDocumentation sd in cce.Annotation.Items)
                {
                    XmlNode node = sd.Markup[0];
                    if (node.Name == "maxDistanceFrom")
                    {
                        double km, lat, lon;
                        if (double.TryParse(node.ChildNodes[0].InnerText, out km) &&
                            double.TryParse(node.ChildNodes[1].InnerText, out lat) &&
                            double.TryParse(node.ChildNodes[2].InnerText, out lon))
                        {
                            if (maxDistancesFrom == null)
                            {
                                maxDistancesFrom = new List <List <double> >();
                                ph.Controls.Add(getMaxDistanceValidator(vem.ID));
                            }
                            List <double> newDist = new List <double>();
                            newDist.Add(km);
                            newDist.Add(lat);
                            newDist.Add(lon);
                            maxDistancesFrom.Add(newDist);
                        }
                    }
                }
            }

            return(ph);
        }