| |||||||||
HtmlContainerControl.InnerHtml PropertySystem.Web.UI.HtmlControls Namespace HtmlContainerControl Class Sets or retrieves the HTML content between the start and end tags of the specified HTML server control. Syntax
This property can only be used programmatically; it cannot be set when declaring the control. Property Value
The property takes a string containing a valid combination of text and HTML tags. Exceptions
RemarksUse the InnerHtml property to programmatically modify the content, including HTML markup, between the opening and closing tags of an HTML server control. When setting the property, the given string completely replaces the existing content of the object, except for <html>, <head>, and <title> elements. Unlike the InnerText property, InnerHtml does not automatically encode special characters to and from HTML character entities, which makes it suitable for including HTML markup. To provide automatic HTML encoding and decoding, use the InnerText property instead. ExampleThe below example illustrates using the InnerHtml property to render a bullet list of items in a <span runat="server"> control. if ( Check1.Checked || Check2.Checked || Check3.Checked ) {
Message.InnerHtml = "Looks like you prefer: <ul>";
if ( Check1.Checked ) Message.InnerHtml += "<li>"+Check1.Value;
if ( Check2.Checked ) Message.InnerHtml += "<li>"+Check2.Value;
if ( Check3.Checked ) Message.InnerHtml += "<li>"+Check3.Value;
Message.InnerHtml += "</ul>";
}
else Message.InnerText = "Looks like you don't prefer anything.";
See AlsoHtmlContainerControl Members InnerText |
| ||||||||
Check out related books at Amazon
© 2000-2008 Rey Nuñez All rights reserved.
If you have any question, comment or suggestion
about this site, please send us a note
You can help support aspxtreme