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
{
40 public HtmlContainerControl () : this ("span") {}
42 public HtmlContainerControl (string tag
) : base(tag
) {}
44 [HtmlControlPersistable (false)]
45 [BrowsableAttribute(false)]
46 [DesignerSerializationVisibility (DesignerSerializationVisibility
.Hidden
)]
47 public virtual string InnerHtml
50 if (Controls
.Count
== 0)
53 bool is_literal
= true;
54 StringBuilder text
= new StringBuilder ();
55 foreach (Control ctrl
in Controls
) {
56 LiteralControl lc
= ctrl
as LiteralControl
;
61 text
.Append (lc
.Text
);
65 throw new HttpException ("There is no literal content!");
67 return text
.ToString ();
72 Controls
.Add (new LiteralControl (value));
73 ViewState
["innerhtml"] = value;
77 [HtmlControlPersistable (false)]
78 [BrowsableAttribute(false)]
79 [DesignerSerializationVisibility (DesignerSerializationVisibility
.Hidden
)]
80 public virtual string InnerText
83 return HttpUtility
.HtmlDecode (InnerHtml
);
87 InnerHtml
= HttpUtility
.HtmlEncode (value);
91 protected override void Render (HtmlTextWriter writer
)
93 RenderBeginTag (writer
);
94 RenderChildren (writer
);
95 RenderEndTag (writer
);
98 protected virtual void RenderEndTag (HtmlTextWriter writer
)
100 writer
.WriteEndTag (TagName
);
103 protected override void RenderAttributes (HtmlTextWriter writer
)
105 ViewState
.Remove ("innerhtml");
106 base.RenderAttributes (writer
);
109 protected override ControlCollection
CreateControlCollection ()
111 return new ControlCollection (this);
114 protected override void LoadViewState (object savedState
)
116 if (savedState
!= null) {
117 base.LoadViewState (savedState
);
118 string inner
= ViewState
["innerhtml"] as string;