public static FormItem <EwfTextBox> GetSubjectFormItem(this EmailMessage emailMessage, string value = "") { return(FormItem.Create( "Subject", new EwfTextBox(value), validationGetter: control => new EwfValidation( (pbv, validator) => { emailMessage.Subject = validator.GetString(new ValidationErrorHandler("subject"), control.GetPostBackValue(pbv), false); if (Regex.Match(emailMessage.Subject, RegularExpressions.HtmlTag, RegexOptions.IgnoreCase).Success) { validator.NoteErrorAndAddMessage("HTML is not allowed in the subject field."); } }))); }
void ControlTreeDataLoader.LoadData() { FormState.ExecuteWithDataModificationsAndDefaultAction( dataModifications, () => { if (hideIfEmpty && !formItems.Any()) { Visible = false; return; } CssClass = CssClass.ConcatenateWithSpace(CssElementCreator.CssClass); if (IncludeButtonWithThisText != null) { // We need to do logic to get the button to be on the right of the row. if (useFormItemListMode && numberOfColumns.HasValue) { var widthOfLastRowWithButton = getFormItemRows(formItems, numberOfColumns.Value).Last().Sum(getCellSpan) + defaultFormItemCellSpan; var numberOfPlaceholdersRequired = 0; if (widthOfLastRowWithButton < numberOfColumns.Value) { numberOfPlaceholdersRequired = numberOfColumns.Value - widthOfLastRowWithButton; } if (widthOfLastRowWithButton > numberOfColumns.Value) { numberOfPlaceholdersRequired = numberOfColumns.Value - ((widthOfLastRowWithButton - numberOfColumns.Value) % numberOfColumns.Value); } numberOfPlaceholdersRequired.Times(() => formItems.Add(getPlaceholderFormItem())); } formItems.Add( FormItem.Create( "", new PostBackButton(new ButtonActionControlStyle(IncludeButtonWithThisText), postBack: EwfPage.Instance.DataUpdatePostBack) { Width = Unit.Percentage(50) }, textAlignment: TextAlignment.Right, cellSpan: defaultFormItemCellSpan)); } Controls.Add(useFormItemListMode ? getTableForFormItemList() : getTableForFormItemTable()); }); }
private int getCellSpan(FormItem formItem) { return(formItem.CellSpan ?? defaultFormItemCellSpan); }
private FormItem <Literal> getPlaceholderFormItem() { return(FormItem.Create("", "".GetLiteralControl(), cellSpan: 1)); }
/// <summary> /// Returns a sequence of two form items. /// </summary> public static IEnumerable <FormItem> Append(this FormItem first, FormItem second) => Enumerable.Empty <FormItem>().Append(first).Append(second);
/// <summary> /// Concatenates form items. /// </summary> public static IEnumerable <FormItem> Concat(this FormItem first, IEnumerable <FormItem> second) => second.Prepend(first);
private FormItem getPlaceholderFormItem() { return(FormItem.Create("", new PlaceHolder().AddControlsReturnThis("".ToComponents().GetControls()), cellSpan: 1)); }