Export (0) Print
Expand All

LinkButton Constructor

Initializes a new instance of the LinkButton class.

[Visual Basic]
Public Sub New()
[C#]
public LinkButton();
[C++]
public: LinkButton();
[JScript]
public function LinkButton();

Remarks

Use this constructor to create and initialize a new instance of the LinkButton control.

Example

[Visual Basic, C#] The following example illustrates how to create and initialize a new instance of the LinkButton control.

[Visual Basic] 
<%@ Page Language="VB" AutoEventWireup="True" %>
<html>
<head>

   <script language="VB" runat="server">
 
      Sub Button_Click(Sender As Object, e As EventArgs) 
         Dim myLinkButton As New LinkButton()
         myLinkButton.Text = "This is a new LinkButton!"
         Page.Controls.Add(myLinkButton)
      End Sub
 
     </script>
 
</head>
<body>
 
   <form runat=server>

      <h3>LinkButton Example</h3>
 
      <asp:Button id="Button1" 
           Text="Create and Show a LinkButton" 
           OnClick="Button_Click" 
           runat="server"/>
 
   </form>

</body>
</html>
   

[C#] 
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
<head>

   <script language="C#" runat="server">
 
      void Button_Click(Object Sender, EventArgs e) 
      {
         LinkButton myLinkButton = new LinkButton();
         myLinkButton.Text = "This is a new LinkButton!";
         Page.Controls.Add(myLinkButton);
      }
 
     </script>
 
</head>
<body>
 
   <form runat=server>

      <h3>LinkButton Example</h3>
 
      <asp:Button id="Button1" 
           Text="Create and Show a LinkButton" 
           OnClick="Button_Click" 
           runat="server"/>
 
   </form>

</body>
</html>
   

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

LinkButton Class | LinkButton Members | System.Web.UI.WebControls Namespace

Show:
© 2014 Microsoft