//
-// System.Web.UI.DataBoundLiteralCOntrol.cs
+// 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)
-//
-
+// 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
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
using System.ComponentModel;
+using System.Security.Permissions;
using System.Text;
namespace System.Web.UI {
+ // CAS - no InheritanceDemand here as the class is sealed
+ [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+ // attributes
[ToolboxItem(false)]
- public sealed class DataBoundLiteralControl : Control
+ 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];
- PreventAutoID ();
+ 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++){
}
}
- protected 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;
}
+
+ string ITextControl.Text {
+ get {
+ return Text;
+ }
+ set {
+ throw new NotSupportedException ();
+ }
+ }
}
}