2008-11-18 Marek Habersack <mhabersack@novell.com>
[mono.git] / mcs / class / System.Web / System.Web.UI.HtmlControls / HtmlContainerControl.cs
index bfe41cfa39a86d09a6816488f9a25c9520297422..f8e45bef2eed8c3299cab141a7e6291d268277eb 100644 (file)
@@ -74,22 +74,19 @@ namespace System.Web.UI.HtmlControls
                        get {
                                if (Controls.Count == 0)
                                        return String.Empty;
-
-                               bool is_literal = true;
-                               StringBuilder text = new StringBuilder ();
-                               foreach (Control ctrl in Controls) {
+                               
+                               if (Controls.Count == 1) {
+                                       Control ctrl = Controls [0];
                                        LiteralControl lc = ctrl as LiteralControl;
-                                       if (lc == null) {
-                                               is_literal = false;
-                                               break;
-                                       }
-                                       text.Append (lc.Text);
-                               }
-                                       
-                               if (!is_literal)
-                                       throw new HttpException ("There is no literal content!");
+                                       if (lc != null)
+                                               return lc.Text;
 
-                               return text.ToString ();
+                                       DataBoundLiteralControl dblc = ctrl as DataBoundLiteralControl;
+                                       if (dblc != null)
+                                               return dblc.Text;
+                               }
+                               
+                               throw new HttpException ("There is no literal content!");
                        }
 
                        set {