HtmlGenericControl Class
Defines the methods, properties, and events for all HTML server control tags not represented by a specific .NET Framework class.
For a list of all members of this type, see HtmlGenericControl Members.
System.Object
System.Web.UI.Control
System.Web.UI.HtmlControls.HtmlControl
System.Web.UI.HtmlControls.HtmlContainerControl
System.Web.UI.HtmlControls.HtmlGenericControl
[Visual Basic] Public Class HtmlGenericControl Inherits HtmlContainerControl [C#] public class HtmlGenericControl : HtmlContainerControl [C++] public __gc class HtmlGenericControl : public HtmlContainerControl [JScript] public class HtmlGenericControl extends HtmlContainerControl
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Remarks
Use this class to represent an HTML server control tag not directly represented by a .NET Framework class, such as <span>, <div>, <body>, and <font>.
For a list of initial property values for an instance of HtmlGenericControl, see the HtmlGenericControl constructor.
CAUTION This control can be used to display user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. ASP.NET provides an input request validation feature to block script and HTML in user input. Validation server controls are also provided to assess user input. For more information, see Validation Server Controls.
Example
[Visual Basic, C#, JScript] The following example demonstrates how to use the HtmlGenericControl class to represent the <body> tag.
[Visual Basic] <%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> <script language="VB" runat="server"> Sub SubmitBtn_Click(sender As Object, e As EventArgs) Body.Attributes("bgcolor") = ColorSelect.Value End Sub 'SubmitBtn_Click </script> </head> <body id=Body runat=server> <h3>HtmlGenericControl Sample</h3> <form runat=server> <p> Select a background color for the page: <p> <select id="ColorSelect" runat="server"> <option>White</option> <option>LightBlue</option> <option>LightGreen</option> <option>Yellow</option> </select> <input type="submit" runat="server" Value="Apply" OnServerClick="SubmitBtn_Click"> </form> </body> </html> [C#] <%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> <script language="C#" runat="server"> void SubmitBtn_Click(Object sender, EventArgs e) { Body.Attributes["bgcolor"] = ColorSelect.Value; } </script> </head> <body id=Body runat=server> <h3>HtmlGenericControl Sample</h3> <form runat=server> <p> Select a background color for the page: <p> <select id="ColorSelect" runat="server"> <option>White</option> <option>LightBlue</option> <option>LightGreen</option> <option>Yellow</option> </select> <input type="submit" runat="server" Value="Apply" OnServerClick="SubmitBtn_Click"> </form> </body> </html> [JScript] <%@ Page Language="JScript" AutoEventWireup="True" %> <html> <head> <script language="jscript" runat="server"> function SubmitBtn_Click(sender: Object, e: EventArgs){ Body.Attributes("bgcolor") = ColorSelect.Value } </script> </head> <body id=Body runat=server> <h3>HtmlGenericControl Sample</h3> <form runat=server> <p> Select a background color for the page: <p> <select id="ColorSelect" runat="server"> <option>White</option> <option>LightBlue</option> <option>LightGreen</option> <option>Yellow</option> </select> <input type="submit" runat="server" Value="Apply" OnServerClick="SubmitBtn_Click"> </form> </body> </html>
[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.Web.UI.HtmlControls
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: System.Web (in System.Web.dll)
See Also
HtmlGenericControl Members | System.Web.UI.HtmlControls Namespace | HtmlContainerControl