2 // System.Web.UI.HtmlControls.HtmlContainerControl.cs
5 // Bob Smith <bob@thestuff.net>
6 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
9 // (c) 2002 Ximian, Inc. (http://www.ximian.com)
13 using System.ComponentModel;
18 //LAMESPEC: The dox talk about HttpException but are very ambigious.
19 //TODO: Check to see if Render really is overridden instead of a LiteralControl being added. It apears that this is the
20 //case due to testing. Anything inside the block is overwritten by the content of this control, so it doesnt apear
21 //to do anything with children.
22 // a doc references this. add? protected override ControlCollection CreateControlCollection();
24 //TODO: If Test.InnerText = Test.InnerHtml without ever assigning anything into InnerHtml, you get this:
25 // Exception Details: System.Web.HttpException: Cannot get inner content of Message because the contents are not literal.
26 //[HttpException (0x80004005): Cannot get inner content of Message because the contents are not literal.]
27 // System.Web.UI.HtmlControls.HtmlContainerControl.get_InnerHtml() +278
28 // ASP.test3_aspx.AnchorBtn_Click(Object Source, EventArgs E) in \\genfs2\www24\bobsmith11\test3.aspx:6
29 // System.Web.UI.HtmlControls.HtmlAnchor.OnServerClick(EventArgs e) +108
30 // System.Web.UI.HtmlControls.HtmlAnchor.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +26
31 // System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
32 // System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +149
33 // System.Web.UI.Page.ProcessRequestMain() +660
36 namespace System.Web.UI.HtmlControls
38 public abstract class HtmlContainerControl : HtmlControl{
45 HtmlContainerControl () : this ("span") {}
47 public HtmlContainerControl (string tag) : base(tag) {}
49 [HtmlControlPersistable (false)]
50 [BrowsableAttribute(false)]
51 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
52 public virtual string InnerHtml
55 if (Controls.Count == 0)
58 bool is_literal = true;
59 StringBuilder text = new StringBuilder ();
60 foreach (Control ctrl in Controls) {
61 LiteralControl lc = ctrl as LiteralControl;
66 text.Append (lc.Text);
70 throw new HttpException ("There is no literal content!");
72 return text.ToString ();
77 Controls.Add (new LiteralControl (value));
79 ViewState.Remove ("innerhtml");
81 ViewState ["innerhtml"] = value;
85 [HtmlControlPersistable (false)]
86 [BrowsableAttribute(false)]
87 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
88 public virtual string InnerText
91 return HttpUtility.HtmlDecode (InnerHtml);
95 InnerHtml = HttpUtility.HtmlEncode (value);
104 override void Render (HtmlTextWriter writer)
106 RenderBeginTag (writer);
107 RenderChildren (writer);
108 RenderEndTag (writer);
111 protected virtual void RenderEndTag (HtmlTextWriter writer)
113 writer.WriteEndTag (TagName);
116 protected override void RenderAttributes (HtmlTextWriter writer)
118 ViewState.Remove ("innerhtml");
119 base.RenderAttributes (writer);
122 protected override ControlCollection CreateControlCollection ()
124 return new ControlCollection (this);
127 protected override void LoadViewState (object savedState)
129 if (savedState != null) {
130 base.LoadViewState (savedState);
131 string inner = ViewState ["innerhtml"] as string;