Link Class

Represents a hyperlink to another Form control on the same mobile page or to an arbitrary URI.

public class System.Web.UI.MobileControls.Link : 
   System.Web.UI.MobileControls.TextControl,
   System.Web.UI.IPostBackEventHandler

Remarks

On all devices, the link is rendered in such a way that the Text property displays on the device to the user. When the user invokes the link, the browser navigates to the specified NavigateURL property. The application must contain code that verifies that a link is browsable on a particular device. For example, the link www.microsoft.com is not browsable on a WML-capable device.

If the Text property is empty, the value in the NavigateURL property is also used for the Text property. Specifically, when the renderer displays a link, it first checks the Text property for the text to display; if that property is empty, it displays the value of the NavigateURL property.

Example

This example shows how to create a Link programmatically and add it to the form as a child control.

<%@ Page Inherits="System.Web.UI.MobileControls.MobilePage" 
   Language="VB" %>
<%@ Register TagPrefix="mobile"
    Namespace="System.Web.UI.MobileControls"
    Assembly="System.Web.Mobile" %>

<script language="vb" runat="server">

Dim Link1 As New Link

Public Sub Page_Load()
   ' Programmatically add a Link and set properties.
   Link1.Text = "Visit Microsoft"
   Link1.NavigateURL = "https://www.microsoft.com"
   Link1.Alignment = Alignment.Left

   ' Add the link to the form as a child control.
   Form1.Controls.Add(Link1)
End Sub
</script>

<mobile:Form id="Form1" runat="server" />
[C#]
<%@ Page Inherits="System.Web.UI.MobileControls.MobilePage" 
   Language="c#" %>
<%@ Register TagPrefix="mobile"
    Namespace="System.Web.UI.MobileControls"
    Assembly="System.Web.Mobile" %>

<script language="c#" runat="server">

Link Link1 = new Link();

public void Page_Load()
{
   // Programmatically add a Link and set properties.
   Link1.Text = "Visit Microsoft";
   Link1.NavigateURL = "https://www.microsoft.com";
   Link1.Alignment = Alignment.Left;

   // Add the link to the form as a child control.
   Form1.Controls.Add(Link1);
}
</script>

<mobile:Form id="Form1" runat="server" />

Requirements

Namespace: System.Web.UI.MobileControls

Assembly: System.Web.Mobile

See Also

Link Control | Form Class | MobilePage Class