个性化阅读
专注于IT技术分析

asp.net linkbutton用法

本文概述

它是充当超链接的服务器Web控件。它用于在网页上显示超链接样式的按钮控件。 ASP.NET提供了一个用于创建LinkBut​​ton的标记,并具有以下语法。

ASP.NET LinkBut​​ton语法

<asp:LinkButton
    AccessKey="string"
    ID="string"
    OnClick="Click event handler"
    OnClientClick="string"
    OnCommand="Command event handler"
    OnDataBinding="DataBinding event handler"
    OnDisposed="Disposed event handler"
    OnInit="Init event handler"
    OnLoad="Load event handler"
    OnPreRender="PreRender event handler"
    OnUnload="Unload event handler"
    PostBackUrl="uri"
    runat="server"
/>

ASP.NET LinkBut​​ton示例

// LinkBut​​tonExample.aspx

<%@ Page Language="C#" AutoEventWireup="true" 
CodeBehind="LinkButtonExample.aspx.cs" Inherits="LinkButtonExample.LinkButtonExample" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <p>It is a hyperlink style button</p>
        </div>
        <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">srcmini</asp:LinkButton>
        <p>
            <asp:Label ID="Label1" runat="server"></asp:Label>
        </p>
    </form>
</body>
</html>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace LinkButtonExample
{
    public partial class LinkButtonExample : System.Web.UI.Page
    {
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            Label1.Text = "Welcome to the srcmini";
        }
    }
}

输出:

单击LinkBut​​ton时将显示一条消息。

赞(0)
未经允许不得转载:srcmini » asp.net linkbutton用法

评论 抢沙发

评论前必须登录!