Пример #1
0
        public override IHtmlString GetHtmlString(BaseFormBuilderRequestContext context, FormField field, IDictionary <string, string> htmlAttributes)
        {
            var sb = new StringBuilder();
            var placeholderText = field.PlaceholderText;

            if (String.IsNullOrEmpty(placeholderText) && context.FormRenderer.HideLabels)
            {
                placeholderText = field.Label;
            }

            sb.AppendFormat(Markup,
                            HttpUtility.HtmlAttributeEncode(field.Name),
                            HttpUtility.HtmlAttributeEncode(field.Id),
                            HttpUtility.HtmlAttributeEncode(placeholderText),
                            Rows,
                            Cols);

            AddHtmlAttribute("class", context.FormRenderer.FormControlClass, htmlAttributes);

            AddReadOnlyAttribute(field, htmlAttributes);
            AddMaxLengthAttribute(field, htmlAttributes);
            RenderExtraHtmlTags(sb, field, htmlAttributes);

            sb.AppendFormat(">{0}</textarea>", HttpUtility.HtmlEncode(field.GetValueAsString()));

            return(new HtmlString(sb.ToString()));
        }
        public override IHtmlString GetHtmlString(BaseFormBuilderRequestContext context, FormField field, IDictionary <string, string> htmlAttributes)
        {
            var sb              = new StringBuilder();
            var renderer        = context.FormRenderer;
            var placeholderText = field.PlaceholderText;

            if (String.IsNullOrEmpty(placeholderText) && renderer.HideLabels)
            {
                placeholderText = field.Label;
            }

            sb.AppendFormat(Markup,
                            EvaluateTextboxType(field),
                            HttpUtility.HtmlAttributeEncode(field.Name),
                            HttpUtility.HtmlAttributeEncode(field.Id),
                            field.Value == null ? String.Empty : HttpUtility.HtmlAttributeEncode(field.GetValueAsString()),
                            HttpUtility.HtmlAttributeEncode(field.Label),
                            HttpUtility.HtmlAttributeEncode(placeholderText));

            AddHtmlAttribute("class", renderer.FormControlClass, htmlAttributes);

            AddReadOnlyAttribute(field, htmlAttributes);
            AddMaxLengthAttribute(field, htmlAttributes);
            RenderExtraHtmlTags(sb, field, htmlAttributes);

            sb.Append(" />");

            return(new HtmlString(sb.ToString()));
        }