protected override void AddAttributesToRender (HtmlTextWriter w)
{
Page page = Page;
if (page != null)
page.VerifyRenderingInServerForm (this);
switch (TextMode) {
case TextBoxMode.MultiLine:
if (Columns != 0)
w.AddAttribute (HtmlTextWriterAttribute.Cols, Columns.ToString (), false);
#if NET_2_0
else
w.AddAttribute (HtmlTextWriterAttribute.Cols, "20", false);
#endif
if (Rows != 0)
w.AddAttribute (HtmlTextWriterAttribute.Rows, Rows.ToString (), false);
#if NET_2_0
else
w.AddAttribute (HtmlTextWriterAttribute.Rows, "2", false);
#endif
if (!Wrap)
w.AddAttribute (HtmlTextWriterAttribute.Wrap, "off", false);
break;
case TextBoxMode.SingleLine:
case TextBoxMode.Password:
if (TextMode == TextBoxMode.Password)
w.AddAttribute (HtmlTextWriterAttribute.Type, "password", false);
else {
w.AddAttribute (HtmlTextWriterAttribute.Type, "text", false);
if (Text.Length > 0)
w.AddAttribute (HtmlTextWriterAttribute.Value, Text);
}
if (Columns != 0)
w.AddAttribute (HtmlTextWriterAttribute.Size, Columns.ToString (), false);
if (MaxLength != 0)
w.AddAttribute (HtmlTextWriterAttribute.Maxlength, MaxLength.ToString (), false);
#if NET_2_0
if (AutoCompleteType != AutoCompleteType.None && TextMode == TextBoxMode.SingleLine)
if (AutoCompleteType != AutoCompleteType.Disabled)
w.AddAttribute (HtmlTextWriterAttribute.VCardName, VCardValues [(int) AutoCompleteType]);
else
w.AddAttribute (HtmlTextWriterAttribute.AutoComplete, "off", false);
#endif
break;
}
#if NET_2_0
if (AutoPostBack) {
w.AddAttribute ("onkeypress", "if (WebForm_TextBoxKeyHandler(event) == false) return false;", false);
if (page != null) {
string onchange = page.ClientScript.GetPostBackEventReference (GetPostBackOptions (), true);
onchange = String.Concat ("setTimeout('", onchange.Replace ("\\", "\\\\").Replace ("'", "\\'"), "', 0)");
w.AddAttribute (HtmlTextWriterAttribute.Onchange, BuildScriptAttribute ("onchange", onchange));
}
} else if (page != null)
page.ClientScript.RegisterForEventValidation (UniqueID, String.Empty);
#else
if (page != null && AutoPostBack)
w.AddAttribute (HtmlTextWriterAttribute.Onchange,
BuildScriptAttribute ("onchange",
page.ClientScript.GetPostBackClientHyperlink (this, "")));
#endif
if (ReadOnly)
w.AddAttribute (HtmlTextWriterAttribute.ReadOnly, "ReadOnly", false);
w.AddAttribute (HtmlTextWriterAttribute.Name, UniqueID);
base.AddAttributesToRender (w);
}