Export (0) Print
Expand All
Expand Minimize

Code: Displaying a Web Page from a LinkLabel Control (Visual C#)

Visual Studio .NET 2003

This example displays a Web page in the default browser when a user clicks a Windows Forms LinkLabel control.

Example

private void Form1_Load(object sender, System.EventArgs e)
{
    linkLabel1.Text = "Click here to get more info.";
    linkLabel1.Links.Add(6, 4, "www.microsoft.com");
}
private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
    System.Diagnostics.Process.Start(e.Link.LinkData.ToString());
}

Compiling the Code

This example requires:

  • A form named Form1 with a LinkLabel control named linkLabel1.
  • An active Internet connection.

Secure programming

The call to the Start method requires full trust. For more information, see SecurityException Class.

See Also

Windows Forms Example Topics | LinkLabel Control (Windows Forms) | LinkLabel Class

Show:
© 2014 Microsoft