public DynamicTime(DynamicTimeXml xml) { _textBox = new TextBox(); _textBox.CausesValidation = false; _mskEditExtender = new MaskedEditExtender(); _mskEditExtender.Mask = xml.Mask; _mskEditExtender.MaskType = xml.MaskedType; _mskEditExtender.InputDirection = xml.InputDirection; //_mskEditExtender.AcceptAMPM = false; //_mskEditExtender.UserTimeFormat = MaskedEditUserTimeFormat.TwentyFourHour; //_mskEditExtender.AutoComplete = true; _mskEditValidator = new MaskedEditValidator(); _mskEditValidator.IsValidEmpty = xml.IsValidEmpty; _mskEditValidator.EnableClientScript = true; _mskEditValidator.Display = ValidatorDisplay.Dynamic; _mskEditValidator.InvalidValueBlurredMessage = "*"; _mskEditValidator.InvalidValueMessage = xml.InvalidValueMessage; _mskEditValidator.EmptyValueMessage = xml.EmptyValueMessage; _mskEditValidator.EmptyValueBlurredText = "*"; this.ValidationGroup = xml.ValidationGroup; this.Visible = xml.Visible; this.ID = xml.Name; this.Controls.Add(_textBox); this.Controls.Add(_mskEditExtender); this.Controls.Add(_mskEditValidator); this._timePickerXml = xml; _textBox.Text = xml.Text; }
public DynamicDatePicker() { _textBox = new TextBox(); _textBox.CausesValidation = false; _textBox.Width = Unit.Pixel(70); _maskEditExtender = new MaskedEditExtender(); _maskEditExtender.ClearMaskOnLostFocus = true; _maskEditValidator = new MaskedEditValidator(); _maskEditValidator.Display = ValidatorDisplay.Dynamic; _maskEditValidator.EnableClientScript = true; _maskEditValidator.IsValidEmpty = false; _maskEditValidator.Text = "*"; _maskEditValidator.EmptyValueBlurredText = "*"; _compareValidator = new CompareValidator(); _compareValidator.Visible = false; _compareValidator.ValueToCompare = "01/01/1900"; _compareValidator.Display = ValidatorDisplay.Dynamic; _compareValidator.Type = ValidationDataType.Date; _compareValidator.EnableClientScript = true; _compareValidator.Text = "*"; this.Controls.Add(_textBox); this.Controls.Add(_maskEditExtender); this.Controls.Add(_maskEditValidator); this.Controls.Add(_compareValidator); }
public DynamicTime() { _textBox = new TextBox(); _textBox.CausesValidation = false; _mskEditExtender = new MaskedEditExtender(); _mskEditExtender.TargetControlID = _textBox.ID; _mskEditExtender.Mask = "99:99"; _mskEditExtender.MaskType = MaskedEditType.Time; _mskEditExtender.AcceptAMPM = false; _mskEditExtender.UserTimeFormat = MaskedEditUserTimeFormat.TwentyFourHour; _mskEditExtender.AutoComplete = true; _mskEditValidator = new MaskedEditValidator(); _mskEditValidator.ControlExtender = _mskEditExtender.ID; _mskEditValidator.ControlToValidate = _textBox.ID; _mskEditValidator.EnableClientScript = true; _mskEditValidator.Display = ValidatorDisplay.Dynamic; _mskEditValidator.InvalidValueBlurredMessage = "*"; _mskEditValidator.InvalidValueMessage = "invalid value message"; _mskEditValidator.EmptyValueMessage = "empty value message"; _mskEditValidator.EmptyValueBlurredText = "*"; this.Controls.Add(_textBox); this.Controls.Add(_mskEditExtender); this.Controls.Add(_mskEditValidator); this._timePickerXml = new DynamicTimeXml(); }
protected override bool EvaluateIsValid() { MaskedEditExtender MaskExt = (MaskedEditExtender)FindControl(ControlExtender); TextBox Target = (TextBox)MaskExt.FindControl(ControlToValidate); base.ErrorMessage = ""; base.Text = ""; string cssError = ""; bool ok = true; if (!this.IsValidEmpty) { if (Target.Text.Trim() == this.InitialValue) { base.ErrorMessage = this.EmptyValueMessage; if (string.IsNullOrEmpty(this.EmptyValueBlurredText)) { base.Text = base.ErrorMessage; } else { base.Text = this.EmptyValueBlurredText; } cssError = MaskExt.OnInvalidCssClass; ok = false; } } if (ok && Target.Text.Length != 0 && this.ValidationExpression.Length != 0) { try { System.Text.RegularExpressions.Regex Regex = new System.Text.RegularExpressions.Regex(this.ValidationExpression); ok = Regex.IsMatch(Target.Text); } catch { ok = false; } } if (ok && Target.Text.Length != 0) { string Culture = MaskExt.CultureName; if (string.IsNullOrEmpty(Culture)) { Culture = System.Globalization.CultureInfo.CurrentCulture.Name; } string CultureAMPMP = ""; if (!string.IsNullOrEmpty(ControlCulture.DateTimeFormat.AMDesignator) && !string.IsNullOrEmpty(ControlCulture.DateTimeFormat.PMDesignator)) { CultureAMPMP = ControlCulture.DateTimeFormat.AMDesignator + ";" + ControlCulture.DateTimeFormat.PMDesignator; } switch (MaskExt.MaskType) { case MaskedEditType.Number: try { decimal numval = System.Decimal.Parse(Target.Text, ControlCulture); } catch { ok = false; } break; case MaskedEditType.DateTime: case MaskedEditType.Date: case MaskedEditType.Time: int tamtext = Target.Text.Length; // gmorgan (25/06/2007) - Added check for AcceptAMPM in MaskedEditExtender to fix bug // with validation in 24hr mode. if (MaskExt.AcceptAMPM && !string.IsNullOrEmpty(CultureAMPMP) && (MaskExt.MaskType == MaskedEditType.Time || MaskExt.MaskType == MaskedEditType.DateTime)) { char[] charSeparators = new char[] { ';' }; string[] ArrAMPM = CultureAMPMP.Split(charSeparators); if (ArrAMPM[0].Length != 0) { tamtext -= (ArrAMPM[0].Length + 1); } } if (MaskedEditCommon.GetValidMask(MaskExt.Mask).Length != tamtext) { ok = false; } if (ok) { try { DateTime dtval = System.DateTime.Parse(Target.Text, ControlCulture); } catch { ok = false; } } break; } if (!ok) { base.ErrorMessage = this.InvalidValueMessage; if (string.IsNullOrEmpty(this.InvalidValueBlurredMessage)) { base.Text = base.ErrorMessage; } else { base.Text = this.InvalidValueBlurredMessage; } cssError = MaskExt.OnInvalidCssClass; } if (ok && (!string.IsNullOrEmpty(this.MaximumValue) || !string.IsNullOrEmpty(this.MinimumValue))) { switch (MaskExt.MaskType) { case MaskedEditType.None: { System.Int32 lenvalue; if (!string.IsNullOrEmpty(this.MaximumValue)) { try { lenvalue = System.Int32.Parse(this.MaximumValue, ControlCulture); ok = (lenvalue >= Target.Text.Length); } catch { base.ErrorMessage = this.InvalidValueMessage; if (string.IsNullOrEmpty(this.InvalidValueBlurredMessage)) { base.Text = base.ErrorMessage; } else { base.Text = this.InvalidValueBlurredMessage; } ok = false; } if (!ok) { base.ErrorMessage = this.MaximumValueMessage; if (string.IsNullOrEmpty(this.MaximumValueBlurredMessage)) { base.Text = base.ErrorMessage; } else { base.Text = this.MaximumValueBlurredMessage; } cssError = MaskExt.OnInvalidCssClass; } } if (!string.IsNullOrEmpty(this.MinimumValue)) { try { lenvalue = System.Int32.Parse(this.MinimumValue, ControlCulture); ok = (lenvalue <= Target.Text.Length); } catch { base.ErrorMessage = this.InvalidValueMessage; if (string.IsNullOrEmpty(this.InvalidValueBlurredMessage)) { base.Text = base.ErrorMessage; } else { base.Text = this.InvalidValueBlurredMessage; } ok = false; } if (!ok) { base.ErrorMessage = this.MinimumValueMessage; if (string.IsNullOrEmpty(this.MinimumValueBlurredText)) { base.Text = base.ErrorMessage; } else { base.Text = this.MinimumValueBlurredText; } cssError = MaskExt.OnInvalidCssClass; } } break; } case MaskedEditType.Number: { decimal numval = System.Decimal.Parse(Target.Text, ControlCulture); decimal Compval; if (!string.IsNullOrEmpty(this.MaximumValue)) { try { Compval = System.Decimal.Parse(this.MaximumValue, ControlCulture); ok = (Compval >= numval); } catch { ok = false; } if (!ok) { base.ErrorMessage = this.MaximumValueMessage; if (string.IsNullOrEmpty(this.MaximumValueBlurredMessage)) { base.Text = base.ErrorMessage; } else { base.Text = this.MaximumValueBlurredMessage; } cssError = MaskExt.OnInvalidCssClass; } } if (!string.IsNullOrEmpty(this.MinimumValue)) { try { Compval = System.Decimal.Parse(this.MinimumValue, ControlCulture); ok = (Compval <= numval); } catch { ok = false; } if (!ok) { base.ErrorMessage = this.MinimumValueMessage; if (string.IsNullOrEmpty(this.MinimumValueBlurredText)) { base.Text = base.ErrorMessage; } else { base.Text = this.MinimumValueBlurredText; } cssError = MaskExt.OnInvalidCssClass; } } break; } case MaskedEditType.DateTime: case MaskedEditType.Date: case MaskedEditType.Time: { DateTime dtval = System.DateTime.Parse(Target.Text, ControlCulture); DateTime dtCompval; if (!string.IsNullOrEmpty(this.MaximumValue)) { try { dtCompval = System.DateTime.Parse(this.MaximumValue, ControlCulture); ok = (dtCompval >= dtval); } catch { ok = false; } if (!ok) { base.ErrorMessage = this.MaximumValueMessage; if (string.IsNullOrEmpty(this.MaximumValueBlurredMessage)) { base.Text = base.ErrorMessage; } else { base.Text = this.MaximumValueBlurredMessage; } cssError = MaskExt.OnInvalidCssClass; } } if (!string.IsNullOrEmpty(this.MinimumValue)) { try { dtCompval = System.DateTime.Parse(this.MinimumValue, ControlCulture); ok = (dtCompval <= dtval); } catch { ok = false; } if (!ok) { base.ErrorMessage = this.MinimumValueMessage; if (string.IsNullOrEmpty(this.MinimumValueBlurredText)) { base.Text = base.ErrorMessage; } else { base.Text = this.MinimumValueBlurredText; } cssError = MaskExt.OnInvalidCssClass; } } break; } } } } if (ok && MaskedEditServerValidator != null) { ServerValidateEventArgs serverValidateEventArgs = new ServerValidateEventArgs(Target.Text, ok); MaskedEditServerValidator(Target, serverValidateEventArgs); ok = serverValidateEventArgs.IsValid; if (!ok) { cssError = MaskExt.OnInvalidCssClass; base.ErrorMessage = this.InvalidValueMessage; if (string.IsNullOrEmpty(this.InvalidValueBlurredMessage)) { base.Text = base.ErrorMessage; } else { base.Text = this.InvalidValueBlurredMessage; } } } if (!ok) { // set CSS at server for browser with not implement client validator script (FF, others) //MaskedEditSetCssClass(value,CSS) string Script = "MaskedEditSetCssClass(" + this.ClientID + ",'" + cssError + "');"; ScriptManager.RegisterStartupScript(this, typeof(MaskedEditValidator), "MaskedEditServerValidator_" + this.ID, Script, true); } return(ok); }
protected override void OnPreRender(System.EventArgs e) { base.OnPreRender(e); if (this.EnableClientScript) { // register Script Resource at current page ScriptManager.RegisterClientScriptResource(this, typeof(MaskedEditValidator), "AjaxControlToolkit.MaskedEdit.MaskedEditValidator.js"); MaskedEditExtender MaskExt = (MaskedEditExtender)FindControl(ControlExtender); TextBox Target = (TextBox)MaskExt.FindControl(ControlToValidate); int FirstMaskPos = -1; int LastMaskPosition = -1; if (MaskExt.ClearMaskOnLostFocus) { FirstMaskPos = 0; LastMaskPosition = MaskedEditCommon.GetValidMask(MaskExt.Mask).Length + 1; } else { FirstMaskPos = MaskedEditCommon.GetFirstMaskPosition(MaskExt.Mask); LastMaskPosition = MaskedEditCommon.GetLastMaskPosition(MaskExt.Mask) + 1; } ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "IsMaskedEdit", true.ToString().ToLower(CultureInfo.InvariantCulture), true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "ValidEmpty", this.IsValidEmpty.ToString().ToLower(CultureInfo.InvariantCulture), true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "MaximumValue", this.MaximumValue, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "MinimumValue", this.MinimumValue, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "InitialValue", this.InitialValue, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "ValidationExpression", this.ValidationExpression, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "ClientValidationFunction", this.ClientValidationFunction, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "TargetValidator", Target.ClientID, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "EmptyValueMessage", this.EmptyValueMessage, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "EmptyValueText", this.EmptyValueBlurredText, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "MaximumValueMessage", this.MaximumValueMessage, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "MaximumValueText", this.MaximumValueBlurredMessage, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "MinimumValueMessage", this.MinimumValueMessage, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "MinimumValueText", this.MinimumValueBlurredText, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "InvalidValueMessage", this.InvalidValueMessage, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "InvalidValueText", this.InvalidValueBlurredMessage, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "InvalidValueCssClass", MaskExt.OnInvalidCssClass, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "CssBlurNegative", MaskExt.OnBlurCssNegative, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "CssFocus", MaskExt.OnFocusCssClass, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "CssFocusNegative", MaskExt.OnFocusCssNegative, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "TooltipMessage", this.TooltipMessage, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "FirstMaskPosition", FirstMaskPos.ToString(CultureInfo.InvariantCulture), true); if (!String.IsNullOrEmpty(MaskExt.CultureName)) { ControlCulture = System.Globalization.CultureInfo.GetCultureInfo(MaskExt.CultureName); } switch (MaskExt.MaskType) { case MaskedEditType.None: { ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "evaluationfunction", "MaskedEditValidatorNone", true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "LastMaskPosition", LastMaskPosition.ToString(CultureInfo.InvariantCulture), true); break; } case MaskedEditType.Number: { string AttibCu = ControlCulture.NumberFormat.CurrencySymbol; string AttibDc = ControlCulture.NumberFormat.CurrencyDecimalSeparator; string AttibTh = ControlCulture.NumberFormat.CurrencyGroupSeparator; if (MaskExt.DisplayMoney != MaskedEditShowSymbol.None) { LastMaskPosition += MaskExt.CultureCurrencySymbolPlaceholder.Length + 1; } if (MaskExt.AcceptNegative != MaskedEditShowSymbol.None) { if (MaskExt.DisplayMoney != MaskedEditShowSymbol.None) { LastMaskPosition++; } else { LastMaskPosition += 2; } } ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "Money", AttibCu, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "Decimal", AttibDc, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "Thousands", AttibTh, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "evaluationfunction", "MaskedEditValidatorNumber", true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "LastMaskPosition", LastMaskPosition.ToString(CultureInfo.InvariantCulture), true); break; } case MaskedEditType.DateTime: { //date string AttibSep = ControlCulture.DateTimeFormat.DateSeparator; char sep = System.Char.Parse(ControlCulture.DateTimeFormat.DateSeparator); string[] arrDate = ControlCulture.DateTimeFormat.ShortDatePattern.Split(sep); string AttibFmt = arrDate[0].Substring(0, 1).ToUpper(ControlCulture); AttibFmt += arrDate[1].Substring(0, 1).ToUpper(ControlCulture); AttibFmt += arrDate[2].Substring(0, 1).ToUpper(ControlCulture); AttibFmt = (MaskExt.UserDateFormat == MaskedEditUserDateFormat.None ? AttibFmt : MaskExt.UserDateFormat.ToString()); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "DateSeparator", AttibSep, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "DateFormat", AttibFmt, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "Century", MaskExt.Century.ToString(CultureInfo.InvariantCulture), true); //time AttibSep = ControlCulture.DateTimeFormat.TimeSeparator; string AttibSyb = ""; if (String.IsNullOrEmpty(ControlCulture.DateTimeFormat.AMDesignator + ControlCulture.DateTimeFormat.PMDesignator)) { AttibSyb = ""; } else { AttibSyb = ControlCulture.DateTimeFormat.AMDesignator + ";" + ControlCulture.DateTimeFormat.PMDesignator; } AttibSyb = (MaskExt.UserTimeFormat == MaskedEditUserTimeFormat.None ? AttibSyb : ""); if (MaskExt.AcceptAMPM) { if (!String.IsNullOrEmpty(AttibSyb)) { sep = System.Char.Parse(AttibSep); string[] arrSyb = AttibSyb.Split(sep); LastMaskPosition += arrSyb[0].Length + 1; } } ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "TimeSeparator", AttibSep, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "AmPmSymbol", AttibSyb, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "evaluationfunction", "MaskedEditValidatorDateTime", true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "LastMaskPosition", LastMaskPosition.ToString(CultureInfo.InvariantCulture), true); break; } case MaskedEditType.Date: { string AttibSep = ControlCulture.DateTimeFormat.DateSeparator; char sep = System.Char.Parse(ControlCulture.DateTimeFormat.DateSeparator); string[] arrDate = ControlCulture.DateTimeFormat.ShortDatePattern.Split(sep); string AttibFmt = arrDate[0].Substring(0, 1).ToUpper(ControlCulture); AttibFmt += arrDate[1].Substring(0, 1).ToUpper(ControlCulture); AttibFmt += arrDate[2].Substring(0, 1).ToUpper(ControlCulture); AttibFmt = (MaskExt.UserDateFormat == MaskedEditUserDateFormat.None ? AttibFmt : MaskExt.UserDateFormat.ToString()); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "DateSeparator", AttibSep, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "DateFormat", AttibFmt, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "Century", MaskExt.Century.ToString(CultureInfo.InvariantCulture), true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "evaluationfunction", "MaskedEditValidatorDate", true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "LastMaskPosition", LastMaskPosition.ToString(CultureInfo.InvariantCulture), true); break; } case MaskedEditType.Time: { string AttibSep = ControlCulture.DateTimeFormat.TimeSeparator; string AttibSyb = ""; if (String.IsNullOrEmpty(ControlCulture.DateTimeFormat.AMDesignator + ControlCulture.DateTimeFormat.PMDesignator)) { AttibSyb = ""; } else { AttibSyb = ControlCulture.DateTimeFormat.AMDesignator + ";" + ControlCulture.DateTimeFormat.PMDesignator; } AttibSyb = (MaskExt.UserTimeFormat == MaskedEditUserTimeFormat.None ? AttibSyb : ""); if (MaskExt.AcceptAMPM) { if (!String.IsNullOrEmpty(AttibSyb)) { char sep = System.Char.Parse(AttibSep); string[] arrSyb = AttibSyb.Split(sep); LastMaskPosition += arrSyb[0].Length + 1; } } ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "TimeSeparator", AttibSep, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "AmPmSymbol", AttibSyb, true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "evaluationfunction", "MaskedEditValidatorTime", true); ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "LastMaskPosition", LastMaskPosition.ToString(CultureInfo.InvariantCulture), true); break; } } } }
protected override void CreateChildControls() { Controls.Clear(); _maskedEdit = new TextBox(); _maskedEdit.ID = "_maskedEdit"; this.Controls.Add(_maskedEdit); _maskedEditValidator = new MaskedEditValidator(); _maskedEditValidator.ID = "_maskedEditValidator"; _maskedEditValidator.ControlToValidate = "_maskedEdit"; _maskedEditValidator.ControlExtender = "_maskedEditExtender"; this.Controls.Add(_maskedEditValidator); if (!this.DesignMode) { _maskedEditExtender = new MaskedEditExtender(); _maskedEditExtender.ID = "_maskedEditExtender"; _maskedEditExtender.TargetControlID = "_maskedEdit"; this.Controls.Add(_maskedEditExtender); } }
public editPropertyFieldTemplate(FeatProperty p, string sdfFile) { if (p.IsReadOnly == true) { Label lbl = new Label(); lbl.Text = p.Value.ToString(); lbl.ID = p.Name; c.Add(lbl); } else if (p.AviableValues != null) { DropDownList ddl = new DropDownList(); ddl.ID = p.Name; for (int i = 0; i < p.AviableValues.Count; i++) { ddl.Items.Add(new ListItem(p.AviableValues[i])); } ddl.SelectedIndex = ddl.Items.IndexOf(ddl.Items.FindByText(p.Value.ToString())); ddl.Style["width"] = "150px"; c.Add(ddl); if (!string.IsNullOrEmpty(sdfFile)) { LiteralControl lnkEditConstraint = new LiteralControl(); lnkEditConstraint.Text = string.Format("<span class='buttonP' onclick='ShowSdfEditorDialog(\"{0}\", \"_FeatureCard_{0}\")'>+</span>", HttpUtility.UrlEncode(p.Name)); ddl.Style["width"] = "130px"; c.Add(lnkEditConstraint); } } else if (p.LookUpValues != null && p.LookUpValues.Count != 0) { DropDownList ddl = new DropDownList(); ddl.ID = p.Name; foreach (var item in p.LookUpValues) { ddl.Items.Add(new ListItem(item.Value, item.Key.ToString())); } if (p.Value == null) ddl.SelectedIndex = 0; else ddl.SelectedIndex = ddl.Items.IndexOf(ddl.Items.FindByValue(p.Value.ToString())); ddl.Style["width"] = "150px"; c.Add(ddl); if (!string.IsNullOrEmpty(sdfFile)) { LiteralControl lnkEditConstraint = new LiteralControl(); lnkEditConstraint.Text = string.Format("<span class='buttonP' onclick='ShowSdfEditorDialog(\"{0}\", \"_FeatureCard_{0}\")'>+</span>", HttpUtility.UrlEncode(p.Name)); ddl.Style["width"] = "130px"; c.Add(lnkEditConstraint); } } else if (p.PropertyType == MgPropertyType.DateTime) { TextBox tb = new TextBox(); tb.ID = p.Name; if (p.Value != null) tb.Text = p.Value.ToString(); tb.Style.Add("margin-left", "2px"); tb.ToolTip = "dd/MM/yyyy"; tb.Attributes.Add("dir", "ltr"); tb.Style.Add("text-align", "right"); c.Add(tb); if (p.Alias == "תאריך עדכון" || p.Alias == "עדכון אחרון") { tb.Enabled = false; return; } tb.CssClass = "dateField"; ImageButton btnPicker = new ImageButton(); btnPicker.ID = string.Format("{0}_btnPicker", p.Name); btnPicker.ImageUrl = "~/Images/calendar.jpg"; btnPicker.ImageAlign = ImageAlign.Middle; btnPicker.Height = new Unit("16px"); c.Add(btnPicker); CalendarExtender ext = new CalendarExtender(); ext.PopupButtonID = btnPicker.ID; ext.TargetControlID = tb.ID; ext.Format = "dd/MM/yyyy"; ext.CssClass = "cal_Theme1"; ext.ID = string.Format("{0}_ext", p.Name); ext.Enabled = true; c.Add(ext); MaskedEditExtender meExt = new MaskedEditExtender(); meExt.Mask = "99/99/9999"; meExt.InputDirection = MaskedEditInputDirection.RightToLeft; meExt.TargetControlID = tb.ID; meExt.MaskType = MaskedEditType.Date; meExt.ID = string.Format("{0}_MaskEditExt", p.Name); c.Add(meExt); } else if (p.PropertyType == MgPropertyType.Boolean) { CheckBox cb = new CheckBox(); cb.ID = p.Name; if (p.Value == null) p.Value = "False"; cb.Checked = bool.Parse(p.Value.ToString()); c.Add(cb); } else { TextBox tb = new TextBox(); tb.ID = p.Name; if (p.Value != null) tb.Text = p.Value.ToString(); else tb.Text = string.Empty; c.Add(tb); } }
/// <summary> /// Crea los controles hijos /// del control. /// </summary> private void CrearControles() { try { this.lblLunes = new Label(); this.lblLunes.ID = "lblLunes"; this.Controls.Add(this.lblLunes); this.lblMartes = new Label(); this.lblMartes.ID = "lblMartes"; this.Controls.Add(this.lblMartes); this.lblMiercoles = new Label(); this.lblMiercoles.ID = "lblMiercoles"; this.Controls.Add(this.lblMiercoles); this.lblJueves = new Label(); this.lblJueves.ID = "lblJueves"; this.Controls.Add(this.lblJueves); this.lblViernes = new Label(); this.lblViernes.ID = "lblViernes"; this.Controls.Add(this.lblViernes); this.lblSabado = new Label(); this.lblSabado.ID = "lblSabado"; this.Controls.Add(this.lblSabado); this.lblDomingo = new Label(); this.lblDomingo.ID = "lblDomingo"; this.Controls.Add(this.lblDomingo); this.lblTarea = new Label(); this.lblTarea.ID = "lblTarea"; this.lblTarea.Text = "Actividad"; this.Controls.Add(this.lblTarea); this.btnAnterior = new ImageButton(); this.btnAnterior.ID = "btnAnterior"; this.btnAnterior.Width = 30; this.btnAnterior.Height = 30; this.btnAnterior.ImageUrl = this.urlAnterior; this.Controls.Add(this.btnAnterior); this.btnAnterior.Click += new ImageClickEventHandler(btnAnterior_Click); this.btnSiguiente = new ImageButton(); this.btnSiguiente.ID = "btnSiguiente"; this.btnSiguiente.Width = 30; this.btnSiguiente.Height = 30; this.btnSiguiente.ImageUrl = this.urlSiguiente; this.Controls.Add(this.btnSiguiente); this.btnSiguiente.Click += new ImageClickEventHandler(btnSiguiente_Click); this.lblSemana = new Label(); this.lblSemana.ID = "lblSemana"; this.Controls.Add(this.lblSemana); this.lblProyecto = new Label(); this.lblProyecto.ID = "lblProyecto"; this.lblProyecto.Text = "Proyectos: "; this.Controls.Add(this.lblProyecto); this.ddlProyectos = new DropDownList(); this.ddlProyectos.Width = 125; this.ddlProyectos.ID = "ddlProyectos"; //this.ddlProyectos.Items.Add(new ListItem("Proyecto")); this.ddlProyectos.AutoPostBack = true; this.ddlProyectos.DataTextField = this.dataTextFieldProyecto; this.ddlProyectos.DataValueField = this.dataValueFieldProyecto; this.ddlProyectos.SelectedIndexChanged += new EventHandler(ddlProyectos_SelectedIndexChanged); this.CargarProyectos(); this.Controls.Add(this.ddlProyectos); this.lnbHoy = new LinkButton(); this.lnbHoy.ID = "lnbHoy"; this.lnbHoy.Text = "Hoy"; this.lnbHoy.Click += new EventHandler(lnbHoy_Click); this.Controls.Add(this.lnbHoy); this.btnImprevisto = new HyperLink(); this.btnImprevisto.ID = "btnImprevisto"; this.btnImprevisto.Text = " + Imprevisto"; this.btnImprevisto.NavigateUrl = urlImprevisto; this.btnImprevisto.CssClass = cssBotonImprevisto; this.Controls.Add(this.btnImprevisto); this.txtCalendario = new TextBox(); this.txtCalendario.ID = "txtCalendario"; this.txtCalendario.Text = FechaCalendario.ToString("dd/MM/yyyy"); this.txtCalendario.AutoPostBack = true; this.txtCalendario.TextChanged += new EventHandler(txtCalendario_TextChanged); this.Controls.Add(this.txtCalendario); this.btnCalendario = new ImageButton(); this.btnCalendario.ID = "btnCalendario"; this.btnCalendario.ImageUrl = UrlBotonCalendario; this.btnCalendario.CausesValidation = false; this.Controls.Add(this.btnCalendario); this.cdeCalendario = new CalendarExtender(); this.cdeCalendario.ID = "cdeCalendario"; this.cdeCalendario.TargetControlID = "txtCalendario"; this.cdeCalendario.PopupButtonID = "btnCalendario"; this.cdeCalendario.Format = "dd/MM/yyyy"; this.Controls.Add(this.cdeCalendario); this.mskDate = new MaskedEditExtender(); this.mskDate.ID = "mskDate"; this.mskDate.TargetControlID = "txtCalendario"; this.mskDate.Mask = "99/99/9999"; this.mskDate.CultureName = "es-ES"; this.mskDate.MessageValidatorTip = true; this.mskDate.MaskType = MaskedEditType.Date; this.mskDate.UserDateFormat = MaskedEditUserDateFormat.DayMonthYear; this.Controls.Add(this.mskDate); //this.mdvDate = new MaskedEditValidator(); //this.mdvDate.ID = "mdvDate"; //this.mdvDate.ControlExtender = "mskDate"; //this.mdvDate.IsValidEmpty = true; //this.mdvDate.ControlToValidate = "txtCalendario"; //this.mdvDate.InvalidValueMessage = "La fecha es inválida"; //this.mdvDate.Display = ValidatorDisplay.Dynamic; //this.mdvDate.TooltipMessage = "Ingrese una fecha con formato dd/mm/yyyy Ejemplo: 25/05/2011"; //this.Controls.Add(this.mdvDate); } catch (Exception po_excepcion) { } }
protected override void CreateChildControls() { base.CreateChildControls(); this.txtDate = new StyledTextBox(); this.txtDate.ID = "txtDate"; this.txtDate.CssClass = "masked_calendar_date"; this.txtDate.ReadOnly = this._readOnly; if (this._readOnly) { this.txtDate.ApplyStyle(this._readOnlyStyle); } else { this.txtDate.ApplyStyle(this._normalStyle); } this.Controls.Add(this.txtDate); this.txtTime = new StyledTextBox(); this.txtTime.ID = "txtTime"; this.txtTime.CssClass = "masked_calendar_time"; this.txtTime.Visible = false; this.txtTime.ReadOnly = this._readOnly; if (this._readOnly) { this.txtTime.ApplyStyle(this._readOnlyStyle); } else { this.txtTime.ApplyStyle(this._normalStyle); } this.Controls.Add(this.txtTime); this.maskDate = new MaskedEditExtender(); this.maskDate.ID = "maskDate"; this.maskDate.TargetControlID = "txtDate"; this.maskDate.MaskType = MaskedEditType.Date; this.maskDate.Mask = "99/99/9999"; this.Controls.Add(this.maskDate); this.maskTime = new MaskedEditExtender(); this.maskTime.ID = "maskTime"; this.maskTime.TargetControlID = "txtTime"; this.maskTime.MaskType = MaskedEditType.Time; this.maskTime.Mask = "99:99"; this.maskTime.AcceptAMPM = false; this.Controls.Add(this.maskTime); this.calDate = new CalendarExtender(); this.calDate.ID = "calDate"; this.calDate.TargetControlID = "txtDate"; this.Controls.Add(this.calDate); this.calDate.Enabled = !this._readOnly; this.calDate.Format = Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern; this.maskDate.CultureName = Thread.CurrentThread.CurrentCulture.Name; }
protected void Page_Load(object sender, EventArgs e) { SuperForm1 = new SuperForm(); SuperForm1.ID = "SuperForm1"; SuperForm1.DataSourceID = "SqlDataSource1"; SuperForm1.AutoGenerateRows = false; SuperForm1.AutoGenerateInsertButton = true; SuperForm1.AutoGenerateEditButton = true; SuperForm1.AutoGenerateDeleteButton = true; SuperForm1.DataKeyNames = new string[] { "EmployeeID" }; SuperForm1.AllowPaging = true; SuperForm1.DefaultMode = DetailsViewMode.Insert; SuperForm1.ItemInserted += SuperForm1_ItemInserted; SuperForm1.ItemCommand += SuperForm1_ItemCommand; Obout.SuperForm.BoundField field1 = new Obout.SuperForm.BoundField(); field1.DataField = "EmployeeID"; field1.HeaderText = "Employee ID"; field1.ReadOnly = true; field1.InsertVisible = false; Obout.SuperForm.BoundField field2 = new Obout.SuperForm.BoundField(); field2.DataField = "FirstName"; field2.HeaderText = "First Name"; field2.Required = true; Obout.SuperForm.BoundField field3 = new Obout.SuperForm.BoundField(); field3.DataField = "LastName"; field3.HeaderText = "Last Name"; field3.Required = true; Obout.SuperForm.BoundField field4 = new Obout.SuperForm.BoundField(); field4.DataField = "BirthDate"; field4.HeaderText = "Birth Date"; field4.DataFormatString = "{0:MM/dd/yyyy}"; field4.ApplyFormatInEditMode = true; field4.Required = true; MaskedEditExtender extender1 = new MaskedEditExtender(); extender1.ID = "MaskedEditExtender1"; extender1.Mask = "99/99/9999"; extender1.MaskType = MaskedEditType.Date; field4.Masks.Add(extender1); Obout.SuperForm.BoundField field5 = new Obout.SuperForm.BoundField(); field5.DataField = "HireDate"; field5.HeaderText = "Hire Date"; field5.DataFormatString = "{0:MM/dd/yyyy}"; field5.ApplyFormatInEditMode = true; field5.Required = true; MaskedEditExtender extender2 = new MaskedEditExtender(); extender2.ID = "MaskedEditExtender2"; extender2.Mask = "99/99/9999"; extender2.MaskType = MaskedEditType.Date; field5.Masks.Add(extender2); Obout.SuperForm.BoundField field6 = new Obout.SuperForm.BoundField(); field6.DataField = "Salary"; field6.HeaderText = "Salary"; field6.Required = true; MaskedEditExtender extender3 = new MaskedEditExtender(); extender3.ID = "MaskedEditExtender3"; extender3.Mask = "9,999,9999"; extender3.MaskType = MaskedEditType.Number; extender3.InputDirection = MaskedEditInputDirection.RightToLeft; field6.Masks.Add(extender3); Obout.SuperForm.BoundField field7 = new Obout.SuperForm.BoundField(); field7.DataField = "HomePhone"; field7.HeaderText = "Home Phone"; MaskedEditExtender extender4 = new MaskedEditExtender(); extender4.ID = "MaskedEditExtender4"; extender4.Mask = "(999)999-9999"; extender4.MaskType = MaskedEditType.Number; field7.Masks.Add(extender4); SuperForm1.Fields.Add(field1); SuperForm1.Fields.Add(field2); SuperForm1.Fields.Add(field3); SuperForm1.Fields.Add(field4); SuperForm1.Fields.Add(field5); SuperForm1.Fields.Add(field6); SuperForm1.Fields.Add(field7); SuperForm1Container.Controls.Add(SuperForm1); }
public EditPropertyFieldTemplate(FeatureProperty p, string sdfFile) { this.c = new List<Control>(); if (p.IsReadOnly) { Label lbl = new Label { Text = (p.Value != null) ? p.Value.ToString() : string.Empty, ID = p.Name }; this.c.Add(lbl); } else { DropDownList ddl; LiteralControl lnkEditConstraint; if (p.AviableValues != null) { ddl = new DropDownList { ID = p.Name }; foreach (string t in from x in p.AviableValues orderby x select x) { ddl.Items.Add(new ListItem(t)); } ddl.SelectedIndex = ddl.Items.IndexOf(ddl.Items.FindByText(p.Value.ToString())); ddl.Style["width"] = "150px"; this.c.Add(ddl); if (!string.IsNullOrEmpty(sdfFile)) { lnkEditConstraint = new LiteralControl { Text = string.Format("<span onclick='ShowSdfEditorDialog(\"{0}\", \"_FeatureCard_{0}\")' style='cursor: pointer;'><img src='{1}' alt='+' width='16' height='16'></span>", HttpUtility.UrlEncode(p.Name), VirtualPathUtility.ToAbsolute("~/Images/Edit.png")) }; ddl.Style["width"] = "115px"; this.c.Add(lnkEditConstraint); } } else if ((p.LookUpValues != null) && (p.LookUpValues.Count != 0)) { ddl = new DropDownList { ID = p.Name }; foreach (KeyValuePair<int, string> item in from x in p.LookUpValues where x.Key != -1 select x) { ddl.Items.Add(new ListItem(item.Value, item.Key.ToString())); } ddl.SelectedIndex = (p.Value == null) ? 0 : ddl.Items.IndexOf(ddl.Items.FindByValue(p.Value.ToString())); ddl.Style["width"] = "150px"; this.c.Add(ddl); if (!string.IsNullOrEmpty(sdfFile)) { lnkEditConstraint = new LiteralControl { Text = string.Format("<span onclick='ShowSdfEditorDialog(\"{0}\", \"_FeatureCard_{0}\")' style='cursor: pointer;'><img src='{1}' alt='+' width='16' height='16'></span></span>", HttpUtility.UrlEncode(p.Name), VirtualPathUtility.ToAbsolute("~/Images/Edit.png")) }; ddl.Style["width"] = "115px"; this.c.Add(lnkEditConstraint); } } else { TextBox tb; switch (p.PropertyType) { case 1: { CheckBox cb = new CheckBox { ID = p.Name }; if (p.Value == null) { p.Value = "False"; } cb.Checked = bool.Parse(p.Value.ToString()); this.c.Add(cb); return; } case 3: { tb = new TextBox { ID = p.Name, ToolTip = "dd/MM/yyyy" }; if (p.Value != null) { tb.Text = p.DisplayedValue; } tb.Style.Add("direction", "ltr"); tb.Style.Add("margin-left", "2px"); tb.Style.Add("text-align", "right"); tb.Style.Add("max-width", "95px"); this.c.Add(tb); if ((p.Alias == "תאריך עדכון") || (p.Alias == "עדכון אחרון")) { tb.Enabled = false; } else { tb.CssClass = "dateField"; ImageButton btnPicker = new ImageButton { ID = string.Format("{0}_btnPicker", p.Name), ImageUrl = "~/Images/calendar.jpg", ImageAlign = ImageAlign.Middle, Height = new Unit("16px") }; this.c.Add(btnPicker); CalendarExtender ext = new CalendarExtender { PopupButtonID = btnPicker.ID, TargetControlID = tb.ID, Format = "dd/MM/yyyy", CssClass = "cal_Theme1", ID = string.Format("{0}_ext", p.Name), Enabled = true }; this.c.Add(ext); MaskedEditExtender meExt = new MaskedEditExtender { Mask = "99/99/9999", InputDirection = MaskedEditInputDirection.RightToLeft, TargetControlID = tb.ID, MaskType = MaskedEditType.Date, ID = string.Format("{0}_MaskEditExt", p.Name) }; this.c.Add(meExt); } return; } } tb = new TextBox { ID = p.Name }; tb.Style.Add(HtmlTextWriterStyle.Width, "100%"); tb.Text = (p.Value != null) ? p.Value.ToString() : string.Empty; this.c.Add(tb); } } }
public DynamicDatePicker(DynamicDatePickerXml xml) { _textBox = new TextBox(); _textBox.CausesValidation = false; _maskEditExtender = new MaskedEditExtender(); _maskEditExtender.ClearMaskOnLostFocus = true; _maskEditValidator = new MaskedEditValidator(); _maskEditValidator.Display = ValidatorDisplay.Dynamic; _maskEditValidator.EnableClientScript = true; _maskEditValidator.IsValidEmpty = false; _maskEditValidator.Text = "*"; _maskEditValidator.EmptyValueBlurredText = "*"; _compareValidator = new CompareValidator(); _compareValidator.Visible = false; _compareValidator.ValueToCompare = "01/01/1900"; _compareValidator.Display = ValidatorDisplay.Dynamic; _compareValidator.Type = ValidationDataType.Date; _compareValidator.EnableClientScript = true; _compareValidator.Text = "*"; this.Controls.Add(_textBox); this.Controls.Add(_maskEditExtender); this.Controls.Add(_maskEditValidator); this.Controls.Add(_compareValidator); this.ID = xml.Name; if (xml.Text.HasValue) _textBox.Text = xml.Text.Value.ToString("MM/dd/yyyy"); this.Value = xml.Text; this.IsValidEmpty = xml.IsValidEmpty; this.EmptyValueMessage = xml.EmptyValueMessage; this.InvalidValueMessage = xml.InvalidValueMessage; this.DateTimeFormat = xml.DateTimeFormat; this.ShowOn = xml.ShowOn; this.ValidationGroup = xml.ValidationGroup; this._datePickerXml = xml; this.Visible = xml.Visible; }