ASP.NET LinkButton OnClientClickProperties


LinkButton 控件LinkButton Control

Definition and Usage

The OnClientClick property is used to set the client-side script to run when the LinkButton control is clicked.

In addition to predefined scripts, the script specified in this property can also be run through the LinkButton's "OnClick" event.

Syntax

<asp:LinkButton OnClientClick="func" runat="server" />

Property Description
func The client-side script to run when the LinkButton is clicked.


Examples

The following example runs two scripts when the LinkButton control is clicked:

<script runat="server">
Sub script1(obj As Object, e As EventArgs)
  lblMsg.Text="Hello!"
End Sub
</script>

<html>
<body>

<form runat="server">
<asp:LinkButton OnClick="script1" OnClientClick="script2()"
Text="Click Me" runat="server" />
<br />
<asp:label id="lblMsg" runat="server" />
</form>

<script>
function script2()
  {
  return confirm('Hello!');
  }
</script>
</body>
</html>

Demo Example »

LinkButton 控件LinkButton Control Other Extensions