Example #1
0
        protected override void OnPreRender(EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.LabelResourceKey) || !string.IsNullOrEmpty(this.LabelText))
            {
                this.lbl = Utilities.CreateLabel(this.LabelResourceKey, this.LabelText);
                this.Controls.Add(lbl);
            }

            if (this.IsRequired)
            {
                this.reqValidator = Utilities.CreateRequiredFieldValidator(this.ID, this.ValidationGroup);
                reqValidator.Style.Add("padding", "0px 5px");
                this.Controls.Add(reqValidator);
            }

            if (!this.PropertiesLoaded)
            {
                if (this.ShowPopover)
                {
                    Utilities.AddPopoverAttributes(this.ID, this.Attributes, this.PopoverDiraction, PopoverTriggers.Focus, this.PopoverTextResourceKey);
                }

                this.CssClass = string.Concat(this.CssClass, " ", "form-control");
                this.Attributes.Add("aria-describedby", this.ID + "-addon");

                this.PropertiesLoaded = true;
            }

            base.OnPreRender(e);
        }
        protected override void Render(HtmlTextWriter writer)
        {
            string        lbl = string.Empty, validator = string.Empty, checkall = string.Empty;
            StringBuilder builder = new StringBuilder();

            if (this.EnableCheckAll)
            {
                this.chkCheckAll.RenderControl(new HtmlTextWriter(new StringWriter(builder)));
                checkall = builder.ToString();
            }

            if (!string.IsNullOrEmpty(this.LabelResourceKey) || !string.IsNullOrEmpty(this.LabelText))
            {
                builder.Clear();
                this.lbl.RenderControl(new HtmlTextWriter(new StringWriter(builder)));
                lbl = builder.ToString();
            }

            if (IsRequired)
            {
                builder.Clear();
                this.cstmValidator.RenderControl(new HtmlTextWriter(new StringWriter(builder)));
                validator = builder.ToString();
            }


            writer.Write(string.Format("<div class='control-labels'>{0}{1}{2}{3}</div><div class='chck-list'>", checkall, lbl, this.IsRequired ? "<span class='required'>*</span>" : string.Empty, validator));

            base.Render(writer);

            writer.Write("</div>");
        }
        protected override void OnPreRender(EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.LabelResourceKey) || !string.IsNullOrEmpty(this.LabelText))
            {
                this.lbl = Utilities.CreateLabel(this.LabelResourceKey, this.LabelText);
                this.Controls.Add(lbl);
            }

            base.OnPreRender(e);
        }
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            if (!string.IsNullOrEmpty(this.LabelResourceKey) || !string.IsNullOrEmpty(this.LabelText))
            {
                this.lbl = Utilities.CreateLabel(this.LabelResourceKey, this.LabelText);
                this.Controls.Add(lbl);
            }

            if (this.IsRequired)
            {
                this.reqValidator = string.IsNullOrEmpty(this.RequiredErrorMessage) ? Utilities.CreateRequiredFieldValidator(this.ID, this.ValidationGroup) : Utilities.CreateRequiredFieldValidator(this.ID, this.ValidationGroup, this.RequiredErrorMessage);
                this.Controls.Add(reqValidator);
            }

            if (!this.PropertiesLoaded)
            {
                if (this.ShowPopover)
                {
                    Utilities.AddPopoverAttributes(this.ID, this.Attributes, this.PopoverDiraction, PopoverTriggers.Focus, this.PopoverTextResourceKey);
                }

                this.CssClass = string.Concat(this.CssClass, " ", this.ControlSize.ToString().ToLower());

                this.PropertiesLoaded = true;
            }

            if (this.IncludeDefaultItem && !this.ContainsDefaultItem)
            {
                this.Items.Insert(0, new ListItem(Resources.Choose, ""));
                this.SelectedIndex = 0;
            }

            if (this.Disabled && this.Attributes["disabled"] == null)
            {
                this.Attributes.Add("disabled", "disabled");
            }
            else if (!this.Disabled && this.Attributes["disabled"] != null)
            {
                this.Attributes.Remove("disabled");
            }

            if (this.AddonType.HasValue && this.AddonType.Value == AddonTypes.RadioButton)
            {
                this.addonRadioButton.Checked = this.AddonChecked;
            }

            //this.ApplyOnPreRendarFeatures();
        }
        /// <summary>
        /// Gets or sets the content type that will be used to load the control list items.
        /// This property is for security purpose only to move content types blocking logic from the pages.
        /// </summary>
        //public Nullable<ContentTypes> ContentType
        //{
        //    get { return ViewState.Get<Nullable<ContentTypes>>("ContentType"); }
        //    set { ViewState.Set<Nullable<ContentTypes>>("ContentType", value); }
        //}

        #endregion

        #region Methods

        protected override void OnPreRender(EventArgs e)
        {
            if (this.EnableCheckAll)
            {
                this.chkCheckAll = new CCheckBox();
                this.CssClass    = "checkall";
                this.chkCheckAll.Attributes.Add("data-action", "check-all");
                this.chkCheckAll.Attributes.Add("data-list-id", this.ClientID);
            }

            if (!string.IsNullOrEmpty(this.LabelResourceKey) || !string.IsNullOrEmpty(this.LabelText))
            {
                this.lbl = Utilities.CreateLabel(this.LabelResourceKey, this.LabelText);
                this.Controls.Add(lbl);
            }

            if (this.IsRequired)
            {
                this.cstmValidator = Utilities.CreateCustomValidator(this.ID, this.ValidationGroup, "ValidateCheckBoxList", "RequiredErrorMessage");
                this.cstmValidator.Attributes.Add("data-list-id", this.ClientID);
                this.Controls.Add(cstmValidator);
            }

            if (!this.PropertiesLoaded)
            {
                RepeatDirection       = System.Web.UI.WebControls.RepeatDirection.Vertical;
                this.Width            = Unit.Parse("100%");
                this.PropertiesLoaded = true;
            }
            // Apply security filtration on the drop down list based on the list content type.
            //if (this.ContentType.HasValue && SessionHelper.UserPermissionList != null)
            //{
            //    switch (this.ContentType.Value)
            //    {
            //        case ContentTypes.Country: this.Items.Cast<ListItem>().Where(item => !string.IsNullOrEmpty(item.Value) && !SessionHelper.UserPermissionList.Any(permission => permission.CountryID == int.Parse(item.Value))).ToList().ForEach(this.Items.Remove); break;
            //        case ContentTypes.Company: this.Items.Cast<ListItem>().Where(item => !string.IsNullOrEmpty(item.Value) && !SessionHelper.UserPermissionList.Any(permission => permission.CompanyID == int.Parse(item.Value))).ToList().ForEach(this.Items.Remove); break;
            //        case ContentTypes.Report: this.Items.Cast<ListItem>().Where(item => !string.IsNullOrEmpty(item.Value) && !SessionHelper.UserPermissionList.Any(permission => permission.PermissionID == int.Parse(item.Value))).ToList().ForEach(this.Items.Remove); break;
            //    }
            //}
            base.OnPreRender(e);
        }
Example #6
0
        protected override void OnPreRender(EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.LabelResourceKey) || !string.IsNullOrEmpty(this.LabelText))
            {
                this.lbl = Utilities.CreateLabel(this.LabelResourceKey, this.LabelText);
                this.Controls.Add(lbl);
            }

            if (this.IsRequired)
            {
                this.reqValidator = Utilities.CreateRequiredFieldValidator(this.ID, this.ValidationGroup);
                this.Controls.Add(reqValidator);
            }

            if (!this.PropertiesLoaded)
            {
                this.PropertiesLoaded = true;
            }

            base.OnPreRender(e);
        }
        protected override void OnPreRender(EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.LabelResourceKey) || !string.IsNullOrEmpty(this.LabelText))
            {
                this.lbl = Utilities.CreateLabel(this.LabelResourceKey, this.LabelText);
                this.Controls.Add(lbl);
            }

            if (this.IsRequired)
            {
                this.cstmValidator = Utilities.CreateCustomValidator(this.ID, this.ValidationGroup, "ValidateRadioButtonList", "RequiredErrorMessage");
                this.cstmValidator.Attributes.Add("data-list-id", this.ClientID);
                this.Controls.Add(cstmValidator);
            }

            if (!this.PropertiesLoaded)
            {
                this.CssClass         = "rdio-list";
                this.PropertiesLoaded = true;
            }

            base.OnPreRender(e);
        }
Example #8
0
        protected override void OnLoad(EventArgs e)
        {
            lbl = Utilities.CreateLabel(this.LabelResourceKey);
            lbl.Style.Add("vertical-align", "top");

            fileUpld = new FileUpload
            {
                ID            = "fileUpld_" + this.ClientID,
                AllowMultiple = this.AllowMultiple
            };

            if (this.IsRequired)
            {
                cstmValidator = new CCustomValidator
                {
                    ID = "cstmValidator_" + this.ClientID,
                    ErrorMessageResourceKey  = this.RequiredValidatorErrorMessageResourceKey,
                    ValidationGroup          = this.ValidationGroup,
                    ClientValidationFunction = this.ClientValidationFunctionName
                };

                cstmValidator.Style.Add("position", "relative");
                cstmValidator.Style.Add("top", "-65%");
            }

            hfUpldFiles = new CHiddenField {
                ID = "hfUpldFiles_" + this.ClientID
            };
            hfClear = new CHiddenField {
                ID = "hfClear_" + this.ClientID
            };
            up = new UpdatePanel {
                ID = "up_" + this.ClientID
            };

            uploaderError = new HtmlGenericControl("p")
            {
                ID = "uploaderError_" + this.ClientID
            };
            uploaderError.Attributes.Add("class", "alert alert-error");
            uploaderError.Attributes.Add("style", "display:none;width:50%;");

            up.ContentTemplateContainer.Controls.Add(lbl);

            if (this.IsRequired)
            {
                up.ContentTemplateContainer.Controls.Add(new Label {
                    CssClass = "required", Text = "*"
                });
                up.ContentTemplateContainer.Controls.Add(cstmValidator);
            }

            up.ContentTemplateContainer.Controls.Add(fileUpld);


            up.ContentTemplateContainer.Controls.Add(hfUpldFiles);
            up.ContentTemplateContainer.Controls.Add(hfClear);
            up.ContentTemplateContainer.Controls.Add(uploaderError);
            Controls.Add(up);

            JIC.Crime.View.WebFormHelpers.Utilities.AddCssToPageHeader(this.Page.Header, "/Layouts/css/uploadify_{langType}.css");
            JIC.Crime.View.WebFormHelpers.Utilities.AddJsToPageHeader(this.Page.Header, "/Layouts/js/uploadify/{langCode}.js");
        }
Example #9
0
        protected override void OnLoad(EventArgs e)
        {
            lbl = Utilities.CreateLabel(this.LabelResourceKey);
            lbl.Style.Add("vertical-align", "top");
            fileUpld = new Table()
            {
                ID          = "fileUpld_" + this.ClientID,
                BorderWidth = 1,
                CssClass    = "table table-bordered"
            };
            fileUpld.Style.Add("display", "none");
            TableHeaderRow tr = new TableHeaderRow();

            tr.Cells.Add(new TableHeaderCell()
            {
                Text = "اسم الملف"
            });
            tr.Cells.Add(new TableHeaderCell()
            {
                Text = "نسبة الرفع"
            });
            tr.Cells.Add(new TableHeaderCell()
            {
                Text = "مسح"
            });
            fileUpld.Rows.Add(tr);
            container = new HtmlGenericControl("div")
            {
                ID = "container" + this.ClientID
            };


            container.Controls.Add(btnUploadFinished);

            pickFile = new Image
            {
                ID            = this.ClientID + "pickFile",
                ImageUrl      = "/Layouts/img/uploadify-upload.png",
                AlternateText = "[Select Files]"
            };
            container.Controls.Add(pickFile);


            if (this.IsRequired)
            {
                cstmValidator = new CCustomValidator
                {
                    ID = "cstmValidator_" + this.ClientID,
                    ErrorMessageResourceKey  = this.RequiredValidatorErrorMessageResourceKey,
                    ValidationGroup          = this.ValidationGroup,
                    ClientValidationFunction = this.ClientValidationFunctionName
                };

                cstmValidator.Style.Add("position", "relative");
                cstmValidator.Style.Add("top", "-65%");
            }

            hfUpldFiles = new CHiddenField {
                ID = "hfUpldFiles_" + this.ClientID
            };
            hfClear = new CHiddenField {
                ID = "hfClear_" + this.ClientID
            };
            up = new UpdatePanel {
                ID = "up_" + this.ClientID
            };

            uploaderError = new HtmlGenericControl("p")
            {
                ID = "uploaderError_" + this.ClientID
            };
            uploaderError.Attributes.Add("class", "alert alert-error");
            uploaderError.Attributes.Add("style", "display:none;width:50%;");

            up.ContentTemplateContainer.Controls.Add(lbl);

            if (this.IsRequired)
            {
                up.ContentTemplateContainer.Controls.Add(new Label {
                    CssClass = "required", Text = "*"
                });
                up.ContentTemplateContainer.Controls.Add(cstmValidator);
            }

            up.ContentTemplateContainer.Controls.Add(container);
            up.ContentTemplateContainer.Controls.Add(fileUpld);


            up.ContentTemplateContainer.Controls.Add(hfUpldFiles);
            up.ContentTemplateContainer.Controls.Add(hfClear);
            up.ContentTemplateContainer.Controls.Add(uploaderError);
            Controls.Add(up);

            JIC.Crime.View.WebFormHelpers.Utilities.AddCssToPageHeader(this.Page.Header, "/Layouts/css/jquery.plupload.queue.css");
            JIC.Crime.View.WebFormHelpers.Utilities.AddJsToPageHeader(this.Page.Header, "/Layouts/js/plupload/plupload.full.min.js");
            //JIC.View.Utilities.Utilities.AddJsToPageHeader(this.Page.Header, "/Layouts/js/plupload/i18n/{langCode}.js");
        }
Example #10
0
        protected override void OnPreRender(EventArgs e)
        {
            #region Label
            if (!string.IsNullOrEmpty(this.LabelResourceKey) || !string.IsNullOrEmpty(this.LabelText))
            {
                this.lbl = Utilities.CreateLabel(this.LabelResourceKey, this.LabelText);
                this.Controls.Add(lbl);
            }
            #endregion

            #region Validations
            if (this.IsRequired)
            {
                this.reqValidator = Utilities.CreateRequiredFieldValidator(this.ID, this.ValidationGroup);
                this.Controls.Add(reqValidator);
            }

            if (this.DataType != TextBoxDataTypes.String)
            {
                string validationExpression = string.Empty;
                switch (this.DataType)
                {
                case TextBoxDataTypes.Email: validationExpression = @"\w+([-+.]\w+)*@\w+([-.]\w{2,3})+"; break;

                case TextBoxDataTypes.NationalID:
                    validationExpression = "(2|3)[0-9][0-9][0-1][1-9][0-3][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]";
                    this.MaxLength       = 14;
                    break;

                case TextBoxDataTypes.Year:
                    //validate that the year number is four numbers and starts with 2.
                    validationExpression = @"2\d{3}";
                    this.MaxLength       = 4;
                    break;

                case TextBoxDataTypes.Username:
                    validationExpression = "^[a-zA-Z0-9_]{4,40}$";
                    break;

                case TextBoxDataTypes.Alphapet:
                    validationExpression = "^[\u0600-\u065F\u066A-\u06EF\u06FA-\u06FFa-zA-Z_⁠⁠⁠أإءئؤآي]+[\u0600-\u065F\u066A-\u06EF\u06FA-\u06FFa-zA-Z-_⁠⁠⁠أإءئؤآي]*$";
                    break;

                case TextBoxDataTypes.Int:
                case TextBoxDataTypes.Double:
                case TextBoxDataTypes.Mobile:
                case TextBoxDataTypes.Phone:
                    validationExpression = "^\\d+$" + (this.DataType == TextBoxDataTypes.Double ? "|^-?\\d*\\.\\d+$" : "");
                    if (this.DataType == TextBoxDataTypes.Mobile)
                    {
                        validationExpression = "^01[0125]{1}[0-9]{7,11}";
                        this.MaxLength       = 11;
                    }
                    else if (this.DataType == TextBoxDataTypes.Phone)
                    {
                        validationExpression = "[+-]?[0-9]{5,11}";
                        this.MaxLength       = 11;
                    }
                    if (this.MaxLength == 0)
                    {
                        if (this.DataType == TextBoxDataTypes.Double)
                        {
                            this.MaxLength = 10;
                        }
                        else if (this.DataType == TextBoxDataTypes.Int)
                        {
                            this.MaxLength = 7;
                        }
                    }
                    break;
                }
                this.regValidator = Utilities.CreateRegularExpressionValidator(this.ID, this.ValidationGroup, validationExpression, "InvalidValue");
                this.Controls.Add(regValidator);
            }

            if (!string.IsNullOrEmpty(this.MinValue) && !string.IsNullOrEmpty(this.MaxValue))
            {
                this.rngValidator = Utilities.CreateRangeValidator(this.ID, this.ValidationGroup, this.DataType == TextBoxDataTypes.Int ? ValidationDataType.Integer : ValidationDataType.Double, this.MinValue, this.MaxValue);
                this.Controls.Add(rngValidator);
            }
            else if (!string.IsNullOrEmpty(this.MinValue) && string.IsNullOrEmpty(this.MaxValue))
            {
                this.cmprValidator = Utilities.CreateCompareValidator(this.ID, this.ValidationGroup, this.DataType == TextBoxDataTypes.Int ? ValidationDataType.Integer : ValidationDataType.Double, this.MinValue, ValidationCompareOperator.GreaterThanEqual, "CompareValidatorGreaterThanErrorMessage");
                this.Controls.Add(cmprValidator);
            }
            else if (string.IsNullOrEmpty(this.MinValue) && !string.IsNullOrEmpty(this.MaxValue))
            {
                this.cmprValidator = Utilities.CreateCompareValidator(this.ID, this.ValidationGroup, this.DataType == TextBoxDataTypes.Int ? ValidationDataType.Integer : ValidationDataType.Double, this.MaxValue, ValidationCompareOperator.LessThanEqual, "CompareValidatorLessThanErrorMessage");
                this.Controls.Add(cmprValidator);
            }

            #endregion
            #region AutoCompelete
            if (this.IsAutoCombelete)
            {
                this.hdjson = new CHiddenField();
                this.Controls.Add(hdjson);
            }
            #endregion
            #region Properties

            if (!this.PropertiesLoaded)
            {
                if (this.ShowPopover)
                {
                    Utilities.AddPopoverAttributes(this.ID, this.Attributes, this.PopoverDiraction, PopoverTriggers.Focus, this.PopoverTextResourceKey);
                }

                if (this.IsAutoCombelete)
                {
                    this.CssClass = string.Concat(this.CssClass, "auto");
                }

                if (this.TextMode == TextBoxMode.MultiLine && this.MaxLength > 0)
                {
                    this.Attributes.Add("maxlength", this.MaxLength.ToString());
                }


                if (this.DataType != TextBoxDataTypes.String)
                {
                    switch (this.DataType)
                    {
                    case TextBoxDataTypes.Double:
                        this.Attributes.Add("data-type", this.DataType.ToString().ToLower());
                        break;

                    case TextBoxDataTypes.Int:
                    case TextBoxDataTypes.Mobile:
                    case TextBoxDataTypes.Phone:
                    case TextBoxDataTypes.NationalID:
                        this.Attributes.Add("data-type", TextBoxDataTypes.Int.ToString().ToLower());
                        break;

                    case TextBoxDataTypes.Year:
                        this.Attributes.Add("data-type", TextBoxDataTypes.Int.ToString().ToLower());
                        if (this.DefaultData != TextBoxDefaultData.empty)
                        {
                            this.Text = DateTime.Now.Year.ToString();
                        }

                        break;
                    }
                }


                if (!string.IsNullOrEmpty(this.PlaceholderResourceKey))
                {
                    this.Attributes.Add("placeholder", Resources.ResourceManager.GetString(this.PlaceholderResourceKey));
                }

                this.CssClass = string.Concat(this.CssClass, " ", this.ControlSize.ToString().ToLower());

                if (this.ShowInAddon)
                {
                    this.CssClass = string.Concat(this.CssClass, " form-control");
                }

                this.PropertiesLoaded = true;
            }

            if (this.Disabled && this.Attributes["disabled"] == null)
            {
                this.Attributes.Add("disabled", "disabled");
            }
            else if (!this.Disabled && this.Attributes["disabled"] != null)
            {
                this.Attributes.Remove("disabled");
            }

            if (this.AddonType.HasValue && this.AddonType.Value == AddonTypes.RadioButton)
            {
                this.addonRadioButton.Checked = this.AddonChecked;
            }

            #endregion

            base.OnPreRender(e);
        }