protected override void OnInit(EventArgs e) { base.OnInit(e); this.btnConfirm = new CButton { IconName = "check", Text = string.IsNullOrEmpty(this.ConfirmButtonResourceKey) ? Resources.Accept : Resources.ResourceManager.GetString(this.ConfirmButtonResourceKey), CausesValidation = false, }; btnConfirm.Command += (s, ea) => { if (this.Confirm != null) { this.Confirm(s, new CommandEventArgs(string.Empty, hfArgumentData.Value)); } hfArgumentData.Value = ""; }; this.Controls.Add(this.btnConfirm); hfArgumentData = new CHiddenField { ClientIDMode = System.Web.UI.ClientIDMode.Static, ID = ClientID + "_hfArgumentData" }; Controls.Add(hfArgumentData); this.RegisterScripts(); }
protected override void OnInit(EventArgs e) { base.OnInit(e); if (AllowAddNewItem) { hfNewValueContainer = new CHiddenField { ID = this.ClientID + "_hfNewValueContainer" } } ; }
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"); }
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"); }
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); }