Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Initializes a new instance of the WebControl class.
Overload List
Initializes a new instance of the WebControl class that represents a Span HTML tag.
[Visual Basic] Protected Sub New()
[C++] protected: WebControl();
[JScript] protected function WebControl();
Initializes a new instance of the WebControl class using the specified HTML tag.
[Visual Basic] Public Sub New(HtmlTextWriterTag)
Initializes a new instance of the WebControl class using the specified HTML tag.
[Visual Basic] Protected Sub New(String)
[JScript] protected function WebControl(String);
Example
[Visual Basic, C#, JScript] The following example demonstrates how to use the constructor for the WebControl class to create a TextArea HTML element and display it on the Web Forms page.
[Visual Basic, C#, JScript] Note This example shows how to use one of the overloaded versions of the WebControl constructor. For other examples that might be available, see the individual overload topics.
[Visual Basic]
<%@ Page Language="VB" AutoEventWireup="True" %>
<html>
<head>
<script runat="server">
Sub Button1_Click(sender As Object, e As EventArgs)
Dim wc As New WebControl(HtmlTextWriterTag.Textarea)
PlaceHolder1.Controls.Add(wc)
End Sub
</script>
</head>
<body>
<form runat="server">
<h3>WebControl Constructor Example</h3>
<p>
<asp:PlaceHolder id="PlaceHolder1"
runat="Server"/>
<br>
<asp:Button id="Button1"
Text="Click to create a new TextArea"
OnClick="Button1_Click"
runat="Server" />
<p>
</form>
</body>
</html>
[C#]
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
<head>
<script runat="server">
void Button1_Click(Object sender, EventArgs e)
{
WebControl wc = new WebControl(HtmlTextWriterTag.Textarea);
PlaceHolder1.Controls.Add(wc);
}
</script>
</head>
<body>
<form runat="server">
<h3>WebControl Constructor Example</h3>
<p>
<asp:PlaceHolder id="PlaceHolder1"
runat="Server"/>
<br>
<asp:Button id="Button1"
Text="Click to create a new TextArea"
OnClick="Button1_Click"
runat="Server" />
<p>
</form>
</body>
</html>
[JScript]
<%@ Page Language="JScript" AutoEventWireup="True" %>
<html>
<head>
<script runat="server">
function Button1_Click(sender : Object, e : EventArgs){
var wc : WebControl = new WebControl(HtmlTextWriterTag.Textarea)
PlaceHolder1.Controls.Add(wc)
}
</script>
</head>
<body>
<form runat="server">
<h3>WebControl Constructor Example</h3>
<p>
<asp:PlaceHolder id="PlaceHolder1"
runat="Server"/>
<br>
<asp:Button id="Button1"
Text="Click to create a new TextArea"
OnClick="Button1_Click"
runat="Server" />
<p>
</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.
See Also
WebControl Class | WebControl Members | System.Web.UI.WebControls Namespace
Syntax based on .NET Framework version 1.1.
Documentation version 1.1.1.