HtmlGenericControl Constructors
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Initialiseert een nieuw exemplaar van de HtmlGenericControl klasse.
Overloads
| Name | Description |
|---|---|
| HtmlGenericControl() |
Initialiseert een nieuw exemplaar van de HtmlGenericControl klasse met standaardwaarden. |
| HtmlGenericControl(String) |
Initialiseert een nieuw exemplaar van de HtmlGenericControl klasse met de opgegeven tag. |
HtmlGenericControl()
Initialiseert een nieuw exemplaar van de HtmlGenericControl klasse met standaardwaarden.
public:
HtmlGenericControl();
public HtmlGenericControl();
Public Sub New ()
Voorbeelden
In het volgende codevoorbeeld ziet u hoe u een nieuw exemplaar van de HtmlGenericControl klasse maakt met behulp van de parameterloze constructor.
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
// Create a new HtmlGenericControl.
HtmlGenericControl NewControl = new HtmlGenericControl();
// Set the properties of the new HtmlGenericControl control.
NewControl.ID = "NewControl";
NewControl.InnerHtml = "This is a dynamically created HTML server control.";
// Add the new HtmlGenericControl to the Controls collection of the
// PlaceHolder control.
ControlContainer.Controls.Add(NewControl);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>HtmlGenericControl Constructor Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3> HtmlGenericControl Constructor Example </h3>
<asp:PlaceHolder ID="ControlContainer"
runat="server"/>
</div>
</form>
</body>
</html>
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Create a new HtmlGenericControl.
Dim NewControl As New HtmlGenericControl()
' Set the properties of the new HtmlGenericControl control.
NewControl.ID = "NewControl"
NewControl.InnerHtml = "This is a dynamically created HTML server control."
' Add the new HtmlGenericControl to the Controls collection of the
' PlaceHolder control.
ControlContainer.Controls.Add(NewControl)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>HtmlGenericControl Constructor Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3> HtmlGenericControl Constructor Example </h3>
<asp:PlaceHolder ID="ControlContainer"
runat="server"/>
</div>
</form>
</body>
</html>
Opmerkingen
Gebruik deze constructor om een nieuw exemplaar van de HtmlGenericControl klasse te maken en te initialiseren met behulp van de standaardwaarden. Het wordt vaak gebruikt om dynamisch een element aan de serverzijde <span> te maken.
In de volgende tabel ziet u de oorspronkelijke eigenschapswaarden voor een exemplaar van HtmlGenericControl.
| Property | Initiële waarde |
|---|---|
TagName |
De letterlijke tekenreeks 'span'. |
Van toepassing op
HtmlGenericControl(String)
Initialiseert een nieuw exemplaar van de HtmlGenericControl klasse met de opgegeven tag.
public:
HtmlGenericControl(System::String ^ tag);
public HtmlGenericControl(string tag);
new System.Web.UI.HtmlControls.HtmlGenericControl : string -> System.Web.UI.HtmlControls.HtmlGenericControl
Public Sub New (tag As String)
Parameters
- tag
- String
De naam van het element waarvoor dit exemplaar van de klasse wordt gemaakt.
Voorbeelden
In het volgende codevoorbeeld ziet u hoe u een nieuw exemplaar van de HtmlGenericControl klasse maakt met behulp van de overbelaste constructor.
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
// Create a new HtmlGenericControl.
HtmlGenericControl NewControl = new HtmlGenericControl("div");
// Set the properties of the new HtmlGenericControl control.
NewControl.ID = "NewControl";
NewControl.InnerHtml = "This is a dynamically created HTML server control.";
// Add the new HtmlGenericControl to the Controls collection of the
// PlaceHolder control.
ControlContainer.Controls.Add(NewControl);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>HtmlGenericControl Constructor Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3> HtmlGenericControl Constructor Example </h3>
<asp:PlaceHolder ID="ControlContainer"
runat="server"/>
</div>
</form>
</body>
</html>
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' Create a new HtmlGenericControl.
Dim NewControl As New HtmlGenericControl("div")
' Set the properties of the new HtmlGenericControl control.
NewControl.ID = "NewControl"
NewControl.InnerHtml = "This is a dynamically created HTML server control."
' Add the new HtmlGenericControl to the Controls collection of the
' PlaceHolder control.
ControlContainer.Controls.Add(NewControl)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>HtmlGenericControl Constructor Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3> HtmlGenericControl Constructor Example </h3>
<asp:PlaceHolder ID="ControlContainer"
runat="server"/>
</div>
</form>
</body>
</html>
Opmerkingen
Gebruik deze constructor om een nieuw exemplaar van de HtmlGenericControl klasse te maken en te initialiseren met behulp van de opgegeven tag. Hiermee kunt u dynamisch elk besturingselementelement voor html-servers maken dat niet rechtstreeks wordt vertegenwoordigd door een .NET Framework-klasse.
In de volgende tabel ziet u de oorspronkelijke eigenschapswaarden voor een exemplaar van HtmlGenericControl.
| Property | Initiële waarde |
|---|---|
TagName |
De waarde van de tag parameter. |
Note
Als de tag parameter is null, wordt de TagName eigenschap ingesteld op String.Empty.