This documentation is archived and is not being maintained.
Label Constructor
.NET Framework 1.1
Initializes a new instance of the Label class.
[Visual Basic] Public Sub New() [C#] public Label(); [C++] public: Label(); [JScript] public function Label();
Remarks
Use this constructor to create and initialize a new instance of the Label class.
Example
[Visual Basic, C#, JScript] The following example shows how to create and initialize a new instance of the Label control.
[Visual Basic] <%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> <script language="VB" runat="server"> Sub Button1_Click(Sender As Object, e As EventArgs) Dim myLabel As New Label() myLabel.Text = "This is a new Label" Page.Controls.Add(myLabel) End Sub </script> </head> <body> <form runat="server"> <h3>Label Example</h3> <asp:Button id="Button1" Text="Create and Show a Label" OnClick="Button1_Click" runat="server"/> </form> </body> </html> [C#] <%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> <script language="C#" runat="server"> void Button1_Click(Object Sender, EventArgs e) { Label myLabel = new Label(); myLabel.Text = "This is a new Label"; Page.Controls.Add(myLabel); } </script> </head> <body> <form runat="server"> <h3>Label Example</h3> <asp:Button id="Button1" Text="Create and Show a Label" OnClick="Button1_Click" runat="server"/> </form> </body> </html> [JScript] <%@ Page Language="JScript" AutoEventWireup="True" %> <html> <head> <script language="JScript" runat="server"> function Button1_Click(Sender :Object, e : EventArgs) { var myLabel : Label = new Label(); myLabel.Text = "This is a new Label"; Page.Controls.Add(myLabel); } </script> </head> <body> <form runat="server"> <h3>Label Example</h3> <asp:Button id="Button1" Text="Create and Show a Label" OnClick="Button1_Click" runat="server"/> </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
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
See Also
Label Class | Label Members | System.Web.UI.WebControls Namespace
Show: