HtmlGenericControl Server Control Declarative Syntax
Creates a server-side control that maps to an HTML element not represented by a specific .NET Framework class, such as <body> and <div>.
<span | body | div | font | others
EnableViewState="False|True"
ID="string"
OnDataBinding="OnDataBinding event handler"
OnDisposed="OnDisposed"
OnInit="OnInit event handler"
OnLoad="OnLoad event handler"
OnPreRender="OnPreRender event handler"
OnServerClick="OnServerClick event handler"
OnUnload="OnUnload event handler"
runat="server"
Visible="False|True" >
contentBetweenTags
</span | body | div | font | others>
This control is created on the server in response to tags that include the runat="server" attribute/value pair in elements that do not map directly to a specific HTML control. These elements include the <span>, <body>, <div>, and <font> elements, among others. The control maps the tag name of the particular element to be used as an HTML control to ASP.NET through the TagName property. This control inherits functionality from the HtmlContainerControl class, which allows you to dynamically change inner content of HTML control tags.
You can use a server-side <span> element to display text generated by event-handler code, whether through user input or from a source you designate in your event handler. You can also use the Page_Load event to generate text in a span control and HTML style attributes to format the text when it is displayed in the browser.
The following example shows how you can generate text to display based on user input in an HtmlInputText control. The HtmlGenericControl, which is created by declaring the <span> element on the page, provides the <span> element with access to the InnerHtml property. This allows you to manipulate the text string assigned to the <span> element.
The following example shows how you can use an HtmlGenericControl to allow a user to modify a page's background color. It also shows how to use the AttributeCollection class to programmatically access the attributes that can be declared on any HTML control.