HtmlContainerControl Class

HtmlContainerControl Class

Serves as the abstract base class for HTML server controls that map to HTML elements that are required to have an opening and a closing tag.

Namespace: System.Web.UI.HtmlControls
Assembly: System.Web (in system.web.dll)

public abstract class HtmlContainerControl : HtmlControl
public abstract class HtmlContainerControl extends HtmlControl
public abstract class HtmlContainerControl extends HtmlControl

The most common controls with a closing tag are the <form>, <table>, <tr>, <td>, <a>, and <span> elements.

The InnerText and InnerHtml properties allow you to manipulate the content between the opening and closing tags of HtmlContainerControl-derived controls.

For a list of initial property values for an instance of HtmlContainerControl, see the HtmlContainerControl constructor.

A new instance of this class is not created directly.

Caution noteCaution

If you use the InnerHtml property to specify the text between the opening and closing tags of an HTML server control, the text is not HTML encoded. This makes it possible to embed script within HTML tags in the text. When using the InnerHtml property, be sure to validate the value to reduce security vulnerabilities. Otherwise, consider using the InnerText property instead.

The following code example demonstrates how to use the InnerHtml property of this class to dynamically generate a message on a Web page.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<script runat="server">

  protected void Page_Load(object sender, EventArgs e)
    Message.InnerHtml = Server.HtmlEncode("Welcome! You accessed this page at: " + DateTime.Now);

<html xmlns="" >
<head runat="server">
    <title>HtmlContainerControl Example</title>
    <form id="form1" runat="server">
      <span id="Message" runat=server></span>    

         Derived Classes

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

© 2016 Microsoft