LinkButton

来源:互联网 发布:傲剑 明玉功数据 编辑:程序博客网 时间:2024/05/24 15:43
LinkButton 类 <AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _ <AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _ Public Class LinkButton _     Inherits WebControl _     Implements IButtonControl, IPostBackEventHandler Visual Basic(用法)Dim instance As LinkButton C#[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] public class LinkButton : WebControl, IButtonControl, IPostBackEventHandler Visual C++[AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)] [AspNetHostingPermissionAttribute(SecurityAction::InheritanceDemand, Level = AspNetHostingPermissionLevel::Minimal)] public ref class LinkButton : public WebControl, IButtonControl, IPostBackEventHandler J#/** @attribute AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal) */ /** @attribute AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal) */ public class LinkButton extends WebControl implements IButtonControl, IPostBackEventHandler JScriptpublic class LinkButton extends WebControl implements IButtonControl, IPostBackEventHandler ASP.NET<asp:LinkButton />  备注 使用 LinkButton 控件可在网页上创建超链接样式的按钮。LinkButton 控件的外观与 HyperLink 控件相同,但功能与 Button 控件相同。如果单击控件时要链接到另一个网页,可以考虑使用 HyperLink 控件。 说明: LinkButton 控件将 JavaScript 呈现给客户端浏览器。客户端浏览器必须启用 JavaScript 才能使该控件正常工作。有关客户端脚本的更多信息,请参见 ASP.NET 网页中的客户端脚本。既可以创建“提交”按钮,也可以创建“命令”按钮。“提交”按钮没有关联的命令名。该按钮仅将网页回发给服务器。默认情况下,LinkButton 控件是“提交”按钮。可以为 Click 事件提供事件处理程序,以便以编程方式控制在用户单击“提交”按钮时执行的操作。另一方面,“命令”按钮有关联的命令名称,如 Sort。设置 CommandName 属性以指定命令名。这使您可以在一个网页上创建多个 LinkButton 控件,并以编程方式确定单击了哪个 LinkButton 控件。还可以对“命令”按钮使用 CommandArgument 属性,以提供有关要执行的命令的附加信息,如指定升序。另外,也可以为 Command 事件提供事件处理程序,以便以编程方式控制在单击“命令”按钮时执行的操作。 警告: 此控件可用来显示用户输入,而该输入可能包含恶意的客户端脚本。在应用程序中显示从客户端发送来的任何信息之前,请检查它们是否包含可执行脚本、SQL 语句或其他代码。ASP.NET 提供输入请求验证功能以阻止用户输入中的脚本和 HTML。还提供验证服务器控件以判断用户输入。有关更多信息,请参见 验证服务器控件语法。默认情况下,单击 LinkButton 控件时执行页验证。页验证确定页上与验证控件关联的输入控件是否均通过该验证控件所指定的验证规则。若要禁止执行页验证,请将 CausesValidation 属性设置为 false。辅助功能 默认情况下,为此控件呈现的标记可能不符合辅助功能标准,例如 Web 内容辅助功能准则 1.0 (WCAG) 优先级 1 准则。有关此控件的辅助功能支持的详细信息,请参见 ASP.NET 控件和辅助功能。  示例 下面的示例说明如何创建 LinkButton 控件,该控件在链接被单击时在 Label 控件中显示文本。 Visual Basic 复制代码<%@ Page Language="VB" AutoEventWireup="True" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html > <head> <title>LinkButton Example</title> <script language="VB" runat="server"> Sub LinkButton_Click(sender As Object, e As EventArgs) Label1.Text = "You clicked the link button" End Sub </script> </head> <body> <form id="form1" runat="server"> <h3>LinkButton Example</h3> <asp:LinkButton id="LinkButton1" Text="Click Me" Font-Names="Verdana" Font-Size="14pt" OnClick="LinkButton_Click" runat="server"/> <br /> <asp:Label id="Label1" runat="server" /> </form> </body> </html> C# 复制代码<%@ Page Language="C#" AutoEventWireup="True" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html > <head> <title>LinkButton Example</title> <script language="C#" runat="server"> void LinkButton_Click(Object sender, EventArgs e) { Label1.Text="You clicked the link button"; } </script> </head> <body> <form id="form1" runat="server"> <h3>LinkButton Example</h3> <asp:LinkButton id="LinkButton1" Text="Click Me" Font-Names="Verdana" Font-Size="14pt" OnClick="LinkButton_Click" runat="server"/> <br /> <asp:Label id="Label1" runat="server" /> </form> </body> </html> JScript 复制代码<%@ Page Language="JScript" AutoEventWireup="True" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html > <head> <title>LinkButton Example</title> <script language="JSCRIPT" runat="server"> function LinkButton_Click(sender : Object, e : EventArgs){ Label1.Text = "You clicked the link button" } </script> </head> <body> <form id="form1" runat="server"> <h3>LinkButton Example</h3> <asp:LinkButton id="LinkButton1" Text="Click Me" Font-Names="Verdana" Font-Size="14pt" OnClick="LinkButton_Click" runat="server"/> <br /> <asp:Label id="Label1" runat="server" /> </form> </body> </html>
原创粉丝点击