X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem.Web%2FSystem.Web.UI%2FDataBoundLiteralControl.cs;h=f37cd4a78d93564eb3673a27af2febe4482f30d3;hb=026a8c44d332b3595814ce0aceba255467cd7b6d;hp=99a66a62200568cc52c70da4b0ac82d5a7776689;hpb=5d9434fcb3acc1ed7d3d30603faae797d672fe65;p=mono.git diff --git a/mcs/class/System.Web/System.Web.UI/DataBoundLiteralControl.cs b/mcs/class/System.Web/System.Web.UI/DataBoundLiteralControl.cs index 99a66a62200..f37cd4a78d9 100644 --- a/mcs/class/System.Web/System.Web.UI/DataBoundLiteralControl.cs +++ b/mcs/class/System.Web/System.Web.UI/DataBoundLiteralControl.cs @@ -6,7 +6,7 @@ // 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 @@ -38,18 +38,16 @@ namespace System.Web.UI { [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; } @@ -57,7 +55,7 @@ namespace System.Web.UI { 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++){ @@ -85,14 +83,18 @@ namespace System.Web.UI { } } -#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 () @@ -109,10 +111,11 @@ namespace System.Web.UI { 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; @@ -121,7 +124,6 @@ namespace System.Web.UI { throw new NotSupportedException (); } } -#endif } }