它是用于创建超链接的控件。它响应单击事件。我们可以用它来引用服务器上的任何网页。
要创建超级链接,我们可以编写代码,也可以使用Visual Studio IDE的拖放功能。此控件列在工具箱中。
这是一个服务器端控件,ASP.NET提供自己的标记来创建它。下面给出了示例。
< asp:HyperLinkID="HyperLink1" runat="server" Text="JavaTpoint" NavigateUrl="www.javatpoint.com" ></asp:HyperLink>
服务器将其呈现为HTML控件,并向浏览器生成以下代码。
<a id="HyperLink1" href="www.javatpoint.com">JavaTpoint</a>
此控件具有自己的属性,如下表所示。
Property | Description |
---|---|
AccessKey | It is used to set keyboard shortcut for the control. |
TabIndex | The tab order of the control. |
BackColor | It is used to set background color of the control. |
BorderColor | It is used to set border color of the control. |
BorderWidth | It is used to set width of border of the control. |
Font | It is used to set font for the control text. |
ForeColor | It is used to set color of the control text. |
Text | It is used to set text to be shown for the control. |
ToolTip | It displays the text when mouse is over the control. |
Visible | To set visibility of control on the form. |
Height | It is used to set height of the control. |
Width | It is used to set width of the control. |
NavigateUrl | It is used to set navigate URL. |
Target | Target frame for the navigate url. |
//用户窗体.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="user-form.aspx.cs" Inherits="asp.netexample.user_form" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:HyperLink ID="HyperLink1" runat="server" Text="JavaTpoint" NavigateUrl="www.javatpoint.com"></asp:HyperLink> </div> </form> </body> </html>
此属性窗口显示超链接控件的属性。
输出:
此链接重定向到Javatpoint主页。
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)