// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// (C) 2002 Ximian, Inc. (http://www.ximian.com)
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[ToolboxItem(false)]
- public sealed class DataBoundLiteralControl : Control
-#if NET_2_0
- , ITextControl
-#endif
+ public sealed class DataBoundLiteralControl : Control, ITextControl
{
- private string [] staticLiterals;
- private string [] dataBoundLiterals;
+ int staticLiteralsCount;
+ string [] staticLiterals;
+ string [] dataBoundLiterals;
public DataBoundLiteralControl (int staticLiteralsCount,
int dataBoundLiteralCount)
{
- staticLiterals = new string [staticLiteralsCount];
+ this.staticLiteralsCount = staticLiteralsCount;
dataBoundLiterals = new string [dataBoundLiteralCount];
AutoID = false;
}
public string Text {
get {
StringBuilder text = new StringBuilder ();
- int stLength = staticLiterals.Length;
+ int stLength = staticLiterals == null ? 0 : staticLiterals.Length;
int dbLength = dataBoundLiterals.Length;
int max = (stLength > dbLength) ? stLength : dbLength;
for (int i = 0; i < max; i++){
}
}
-#if NET_2_0
- protected internal
-#else
- protected
-#endif
- override void Render (HtmlTextWriter output)
+ protected internal override void Render (HtmlTextWriter output)
{
- output.Write (Text);
+ int stLength = staticLiterals == null ? 0 : staticLiterals.Length;
+ int dbLength = dataBoundLiterals.Length;
+ int max = (stLength > dbLength) ? stLength : dbLength;
+
+ for (int i = 0; i < max; i++){
+ if (i < stLength)
+ output.Write (staticLiterals [i]);
+ if (i < dbLength)
+ output.Write (dataBoundLiterals [i]);
+ }
}
protected override object SaveViewState ()
public void SetStaticString (int index, string s)
{
+ if (staticLiterals == null)
+ staticLiterals = new string [staticLiteralsCount];
staticLiterals [index] = s;
}
-#if NET_2_0
string ITextControl.Text {
get {
return Text;
throw new NotSupportedException ();
}
}
-#endif
}
}