blob: 092cb52719dd7333b72897568992fcd33c9d7fa1 (
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
|
//
// System.Web.UI.DataBoundLiteralCOntrol.cs
//
// Authors:
// Duncan Mak (duncan@ximian.com)
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// (C) 2002 Ximian, Inc. (http://www.ximian.com)
//
using System;
using System.ComponentModel;
using System.Text;
namespace System.Web.UI {
[ToolboxItem(false)]
public sealed class DataBoundLiteralControl : Control
{
private string [] staticLiterals;
private string [] dataBoundLiterals;
public DataBoundLiteralControl (int staticLiteralsCount,
int dataBoundLiteralCount)
{
staticLiterals = new string [staticLiteralsCount];
dataBoundLiterals = new string [dataBoundLiteralCount];
PreventAutoID ();
}
public string Text {
get {
StringBuilder text = new StringBuilder ();
int stLength = staticLiterals.Length;
int dbLength = dataBoundLiterals.Length;
int max = (stLength > dbLength) ? stLength : dbLength;
for (int i = 0; i < max; i++){
if (i < stLength)
text.Append (staticLiterals [i]);
if (i < dbLength)
text.Append (dataBoundLiterals [i]);
}
return text.ToString ();
}
}
protected override ControlCollection CreateControlCollection ()
{
return new EmptyControlCollection (this);
}
protected override void LoadViewState (object savedState)
{
if (savedState != null) {
Array source = (Array) savedState;
if (source.Length == dataBoundLiterals.Length)
source.CopyTo (dataBoundLiterals, 0);
}
}
protected override void Render (HtmlTextWriter output)
{
output.Write (Text);
}
protected override object SaveViewState ()
{
if (dataBoundLiterals.Length == 0)
return null;
return dataBoundLiterals;
}
public void SetDataBoundString (int index, string s)
{
dataBoundLiterals [index] = s;
}
public void SetStaticString (int index, string s)
{
staticLiterals [index] = s;
}
}
}
|