1 /* System.Web.UI.HtmlControls
3 * Leen Toelen (toelen@hotmail.com)
9 using System
.ComponentModel
;
10 using System
.Globalization
;
11 using System
.Collections
.Specialized
;
13 namespace System
.Web
.UI
.HtmlControls
{
15 [DefaultEvent("ServerChange")]
16 [ValidationProperty("Value")]
17 public class HtmlTextArea
: HtmlContainerControl
, IPostBackDataHandler
{
19 private static readonly object EventServerChange
= new object ();
21 public HtmlTextArea(): base("textarea"){}
24 [WebCategory("Appearance")]
25 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
28 string attr
= Attributes
["cols"];
30 return Int32
.Parse(attr
, CultureInfo
.InvariantCulture
);
35 Attributes
["cols"] = AttributeToString(value);
40 [WebCategory("Appearance")]
41 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
44 string attr
= Attributes
["rows"];
46 return Int32
.Parse(attr
, CultureInfo
.InvariantCulture
);
51 Attributes
["rows"] = AttributeToString(value);
56 [WebCategory("Appearance")]
57 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
68 [WebCategory("Behavior")]
69 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
70 public virtual string Name
{
72 if (UniqueID
!= null){
80 [WebCategory("Action")]
81 [WebSysDescription("Fires when the text within the control changes.")]
82 public event EventHandler ServerChange
{
84 Events
.AddHandler(EventServerChange
, value);
87 Events
.RemoveHandler(EventServerChange
, value);
91 protected virtual void OnServerChange(EventArgs e
){
93 handler
= (EventHandler
) Events
[EventServerChange
];
99 bool IPostBackDataHandler
.LoadPostData (string postDataKey
,
100 NameValueCollection postCollection
)
102 string currentValue
= Value
;
103 string postedValue
= postCollection
[postDataKey
];
104 if (!currentValue
.Equals(postedValue
) && currentValue
!= null){
105 Value
= HttpUtility
.HtmlEncode(postedValue
);
111 protected override void RenderAttributes(HtmlTextWriter writer
){
112 writer
.WriteAttribute("name", Name
);
113 Attributes
.Remove("name");
114 base.RenderAttributes(writer
);
117 void IPostBackDataHandler
.RaisePostDataChangedEvent ()
119 OnServerChange (EventArgs
.Empty
);
122 protected override void OnPreRender(EventArgs e
){
123 if(Events
[EventServerChange
]==null || Disabled
){
124 ViewState
.SetItemDirty("value",false);
128 protected override void AddParsedSubObject(object obj
){
129 if (obj
is LiteralControl
|| obj
is DataBoundLiteralControl
)
130 base.AddParsedSubObject(obj
);
132 throw new NotSupportedException("HtmlTextArea cannot have children of Type " + obj
.GetType().Name
);
135 } // class HtmlTextArea
136 } // namespace System.Web.UI.HtmlControls