Beispiel #1
0
        protected override void Render(HtmlTextWriter writer)
        {
            if (IsWrap)
            {
                var cssClassWrapDefault = TextMode == eTextMode.Multiline ? "textarea-wrap" : "input-wrap";
                writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClassWrapDefault + (CssClassWrap.IsNotEmpty() ? " " + CssClassWrap : ""));
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
            }

            if (Placeholder.IsNotEmpty())
            {
                writer.AddAttribute("placeholder", Placeholder);
            }

            if (DefaultButtonID.IsNotEmpty())
            {
                writer.AddAttribute("onkeyup", string.Format("defaultButtonClick('{0}', event)", DefaultButtonID));
            }

            if (ReadOnly)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.ReadOnly, "readonly");
            }

            if (Disabled)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
            }

            if (MaxLength != 0)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Maxlength, MaxLength.ToString());
            }


            writer.AddAttribute(HtmlTextWriterAttribute.Id, ID);
            writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID);

            writer.AddAttribute(HtmlTextWriterAttribute.Class, string.Format("{0}{1}{2}",
                                                                             CssClass.IsNotEmpty() ? CssClass : string.Empty,
                                                                             ValidationType != eValidationType.None ? " valid-" + ValidationType.ToString().ToLower() : string.Empty,
                                                                             ValidationGroup.IsNotEmpty() ? " group-" + ValidationGroup : string.Empty));
            if (TextMode == eTextMode.Text || TextMode == eTextMode.Password)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Type, TextMode.ToString().ToLower());
            }

            if (TextMode == eTextMode.Multiline)
            {
                writer.RenderBeginTag(HtmlTextWriterTag.Textarea);
                writer.Write(Text);
            }
            else
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Value, Text ?? string.Empty);
                writer.RenderBeginTag(HtmlTextWriterTag.Input);
            }
            writer.RenderEndTag();


            if (IsWrap)
            {
                writer.RenderEndTag();
            }
        }