blob: 9bea972173dcb96dd7aad85a2a5a2cb6a87a0d10 (
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
|
//
// System.Web.UI.HtmlControls.HtmlControl.cs
//
// Author
// Bob Smith <bob@thestuff.net>
//
//
// (C) Bob Smith
//
using System;
using System.Globalization;
using System.Web;
using System.Web.UI;
namespace System.Web.UI.HtmlControls{
public abstract class HtmlControl : Control, IAttributeAccessor
{
private string _tagName = "span";
private AttributeCollection _attributes;
private bool _disabled = false;
public HtmlControl() : this ("span") {}
public HtmlControl(string tag)
{
_tagName = tag;
}
protected override ControlCollection CreateControlCollection ()
{
return new EmptyControlCollection (this);
}
internal static string AttributeToString(int n){
if (n != -1)return n.ToString(NumberFormatInfo.InvariantInfo);
return null;
}
internal static string AttributeToString(string s){
if (s != null && s.Length != 0) return s;
return null;
}
internal void PreProcessRelativeReference(HtmlTextWriter writer, string attribName){
string attr = Attributes[attribName];
if (attr != null){
if (attr.Length != 0){
try{
attr = ResolveUrl(attr);
}
catch (Exception e) {
throw new HttpException(attribName + " property had malformed url");
}
writer.WriteAttribute(attribName, attr);
Attributes.Remove(attribName);
}
}
}
string System.Web.UI.IAttributeAccessor.GetAttribute(string name){
return Attributes[name];
}
void System.Web.UI.IAttributeAccessor.SetAttribute(string name, string value){
Attributes[name] = value;
}
protected virtual void RenderBeginTag (HtmlTextWriter writer)
{
writer.WriteBeginTag (TagName);
RenderAttributes (writer);
writer.Write ('>');
}
protected override void Render (HtmlTextWriter writer)
{
RenderBeginTag (writer);
}
protected virtual void RenderAttributes(HtmlTextWriter writer){
if (ID != null){
writer.WriteAttribute("id",ClientID);
}
Attributes.Render(writer);
}
public AttributeCollection Attributes
{
get {
if (_attributes == null)
_attributes = new AttributeCollection (ViewState);
return _attributes;
}
}
public bool Disabled
{
get { return _disabled; }
set { _disabled = value; }
}
public CssStyleCollection Style
{
get { return Attributes.CssStyle; }
}
public virtual string TagName
{
get { return _tagName; }
}
protected override bool ViewStateIgnoresCase
{
get {
return true;
}
}
}
}
|