blob: 382fc1a559b958f76ce9589032b5892ff99f0dc2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
/* System.Web.UI.HtmlControls
* Authors
* Leen Toelen (toelen@hotmail.com)
*/
using System;
using System.Web;
using System.Web.UI;
using System.ComponentModel;
using System.Globalization;
using System.Collections.Specialized;
namespace System.Web.UI.HtmlControls{
[DefaultEvent("ServerChange")]
[ValidationProperty("Value")]
public class HtmlTextArea : HtmlContainerControl, IPostBackDataHandler{
private static readonly object EventServerChange = new object ();
public HtmlTextArea(): base("textarea"){}
[DefaultValue("")]
[WebCategory("Appearance")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public int Cols{
get{
string attr = Attributes["cols"];
if (attr != null){
return Int32.Parse(attr, CultureInfo.InvariantCulture);
}
return -1;
}
set{
Attributes["cols"] = AttributeToString(value);
}
}
[DefaultValue("")]
[WebCategory("Appearance")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public int Rows{
get{
string attr = Attributes["rows"];
if (attr != null){
return Int32.Parse(attr, CultureInfo.InvariantCulture);;
}
return -1;
}
set{
Attributes["rows"] = AttributeToString(value);
}
}
[DefaultValue("")]
[WebCategory("Appearance")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string Value{
get{
return InnerHtml;
}
set{
InnerHtml = value;
}
}
[DefaultValue("")]
[WebCategory("Behavior")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual string Name{
get{
if (UniqueID != null){
return UniqueID;
}
return String.Empty;
}
set{}
}
[WebCategory("Action")]
[WebSysDescription("Fires when the text within the control changes.")]
public event EventHandler ServerChange{
add{
Events.AddHandler(EventServerChange, value);
}
remove{
Events.RemoveHandler(EventServerChange, value);
}
}
protected virtual void OnServerChange(EventArgs e){
EventHandler handler;
handler = (EventHandler) Events[EventServerChange];
if(handler != null){
handler (this, e);
}
}
bool IPostBackDataHandler.LoadPostData (string postDataKey,
NameValueCollection postCollection)
{
string currentValue = Value;
string postedValue = postCollection[postDataKey];
if (!currentValue.Equals(postedValue) && currentValue != null){
Value = HttpUtility.HtmlEncode(postedValue);
return true;
}
return false;
}
protected override void RenderAttributes(HtmlTextWriter writer){
writer.WriteAttribute("name", Name);
Attributes.Remove("name");
base.RenderAttributes(writer);
}
void IPostBackDataHandler.RaisePostDataChangedEvent ()
{
OnServerChange (EventArgs.Empty);
}
protected override void OnPreRender(EventArgs e){
if(Events[EventServerChange]==null || Disabled){
ViewState.SetItemDirty("value",false);
}
}
protected override void AddParsedSubObject(object obj){
if (obj is LiteralControl || obj is DataBoundLiteralControl)
AddParsedSubObject(obj);
else
throw new NotSupportedException("HtmlTextArea cannot have children of Type " + obj.GetType().Name);
}
} // class HtmlTextArea
} // namespace System.Web.UI.HtmlControls
|