ASP.NET - HyperLink

ASP.NET - HyperLink 首页 / ASP.Net MVC入门教程 / ASP.NET - HyperLink

它是用于创建超链接的控件。它响应单击事件。我们可以用它来引用服务器上的任何网页。

要创建超级链接,我们可以编写代码,也可以使用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>

此属性窗口显示超链接控件的属性。

ASP HyperLink 1

输出:

ASP HyperLink 2

此链接重定向到Javatpoint主页。

ASP HyperLink 3




祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

深入拆解Java虚拟机 -〔郑雨迪〕

邱岳的产品实战 -〔邱岳〕

从0开始学微服务 -〔胡忠想〕

大规模数据处理实战 -〔蔡元楠〕

透视HTTP协议 -〔罗剑锋(Chrono)〕

编译原理实战课 -〔宫文学〕

徐昊 · TDD项目实战70讲 -〔徐昊〕

林外 · 专利写作第一课 -〔林外〕

云计算的必修小课 -〔吕蕴偲〕

好记忆不如烂笔头。留下您的足迹吧 :)