您的位置:首页 > 编程语言 > ASP

Web Server Controls->ASP.NET LinkButton Control

2007-03-27 09:30 239 查看

Definition and Usage

The LinkButton control is used to create a hyperlink button.

Note: This control looks like a HyperLink control but has the same functionality as the Button control!

Properties

PropertyDescription
CausesValidationBy default, a page is validated when a Button control is clicked. To prevent a page from being validated when clicking on a Button control, set this property to "false"
CommandThe command associated with the Command event
CommandArgumentAdditional information about the command to perform
idA unique id for the control
OnClickThe name of the function to be executed when the link is clicked
runatSpecifies that the control is a server control. Must be set to "server"
TextThe text to display for the link

Examples

LinkButton
ASPX Source:

<script runat="server">
Sub lblClick(sender As Object, e As EventArgs)
Label1.Text="You clicked the LinkButton control"
End Sub
</script>

<html>
<body>

<form runat="server">
<asp:LinkButton Text="Click me!" OnClick="lblClick" runat="server" />
<p><asp:Label id="Label1" runat="server" /></p>
</form>

</body>
</html>

Output Result:

Click me!
IF you click the linkbutton "Click me!',it will show:

Click me!
You clicked the LinkButton control

In this example we declare one LinkButton control and one Label control in an .aspx file. When the user clicks on the link, the lbClick subroutine is executed. The subroutine sends the text "You clicked the LinkButton control" to the Label control.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: