Export (0) Print
Expand All

HyperLink.Text Property

Gets or sets the text caption for the HyperLink control.

[Visual Basic]
Public Overridable Property Text As String
[C#]
public virtual string Text {get; set;}
[C++]
public: __property virtual String* get_Text();
public: __property virtual void set_Text(String*);
[JScript]
public function get Text() : String;
public function set Text(String);

Property Value

The text caption for the HyperLink control. The default value is String.Empty.

Remarks

The HyperLink control can be displayed as text or an image. Use the Text property to specify the text to display for the HyperLink control.

If both the Text and ImageUrl properties are set, the ImageUrl property takes precedence. If the image is unavailable, the text in the Text property is displayed. In browsers that support ToolTip functionality, the Text property also becomes the ToolTip.

CAUTION   This control can be used to display user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. ASP.NET provides an input request validation feature to block script and HTML in user input. Validation server controls are also provided to assess user input. For more information, see Validation Server Controls.

Example

[Visual Basic, C#, JScript] The following example demonstrates how to use the Text property to specify the text to display for the HyperLink control.

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

</head>
<body>

    <h3>HyperLink Sample</h3>

    Click on the HyperLink:<br>  

    <asp:HyperLink id="hyperlink1" 
                   NavigateUrl="http://www.microsoft.com"
                   Text="Microsoft Official Site"
                   Target="_new"
                   runat="server"/>       

</body>
</html>


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

</head>
<body>

    <h3>HyperLink Sample</h3>

    Click on the HyperLink:<br>  

    <asp:HyperLink id="hyperlink1" 
                   NavigateUrl="http://www.microsoft.com"
                   Text="Microsoft Official Site"
                   Target="_new"
                   runat="server"/>       

</body>
</html>


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

</head>
<body>

    <h3>HyperLink Sample</h3>

    Click on the HyperLink:<br>  

    <asp:HyperLink id="hyperlink1" 
                   NavigateUrl="http://www.microsoft.com"
                   Text="Microsoft Official Site"
                   Target="_new"
                   runat="server"/>       

</body>
</html>

[C++] No example is available for C++. To view a Visual Basic, C#, or JScript 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

HyperLink Class | HyperLink Members | System.Web.UI.WebControls Namespace | ImageUrl

Show:
© 2014 Microsoft