blob: 0f7afa43778063d6f4663381f216b8ec156a4a19 (
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
|
//
// System.Web.UI.WebControls.Label.cs
//
// Authors:
// Gaurav Vaish (gvaish@iitk.ac.in)
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) Gaurav Vaish (2002)
// (C) 2003 Andreas Nahr
//
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Web;
using System.Web.UI;
namespace System.Web.UI.WebControls
{
[DefaultProperty("Text")]
[Designer("System.Web.UI.Design.WebControls.LabelDesigner, " + Consts.AssemblySystem_Design, typeof (IDesigner))]
[DataBindingHandler("System.Web.UI.Design.TextDataBindingHandler, " + Consts.AssemblySystem_Design)]
[ControlBuilder(typeof(LabelControlBuilder))]
[ParseChildren(false)]
[ToolboxData("<{0}:Label runat=\"server\">Label</{0}:Label>")]
public class Label : WebControl
{
public Label (): base ()
{
}
internal Label (HtmlTextWriterTag tagKey) : base (tagKey)
{
}
[DefaultValue (""), Bindable (true), WebCategory ("Appearance")]
[PersistenceMode (PersistenceMode.InnerDefaultProperty)]
[WebSysDescription ("The text that should be shown on this Label.")]
public virtual string Text
{
get {
object o = ViewState ["Text"];
return (o == null) ? String.Empty : (string) o;
}
set { ViewState ["Text"] = value; }
}
protected override void AddParsedSubObject (object obj)
{
if(HasControls ()){
base.AddParsedSubObject (obj);
return;
}
if(obj is LiteralControl){
Text = ((LiteralControl) obj).Text;
return;
}
if(Text.Length > 0){
base.AddParsedSubObject (new LiteralControl (Text));
Text = String.Empty;
}
base.AddParsedSubObject (obj);
}
protected override void LoadViewState (object savedState)
{
if(savedState != null) {
base.LoadViewState (savedState);
string savedText = ViewState ["Text"] as string;
if(savedText != null)
Text = savedText;
}
}
protected override void RenderContents (HtmlTextWriter writer)
{
if(HasControls ())
base.RenderContents (writer);
else
writer.Write (Text);
}
}
}
|