ASP.NET OnClientClick Property
Complete Button Control Reference
Definition and Usage
The OnClientClick property is used to sets a client side script to be run
when the Button control is clicked.
The script specified in this property is run by the Button's event "OnClick"
in addition to the predefined script.
Syntax
<asp:Button OnClientClick="func" runat="server" />
|
| Attribute |
Description |
| func |
Client side script to be run when button is clicked |
Example
The following example runs two scripts when the Button 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:Button OnClick="script1" OnClientClick="script2()"
Text="Click Me" runat="server" />
<br />
<asp:label id="lblMsg" runat="server" />
</form>
<script type="text/javascript">
function script2()
{
return confirm('Hello!');
}
</script>
</body>
</html>
|
Try-It-Yourself Demos
Run two scripts with one button control
Complete Button Control Reference
Unlimited Disk and Transfer Hosting - New from Go Daddy!
Go Daddy Unlimited Hosting is the reliable, cost-effective
choice for site owners who want superior speed and reliability.
Available for Linux or Windows, our Unlimited Hosting accounts
come with unlimited disk space and bandwidth, 1,000 email
accounts, 50 MySQL Databases, a FREE SSL Certificate and over
50 FREE downloadable applications and utilities available through
our exclusive Hosting Connections. Count on the world’s largest
hostname provider to keep your site up and running—even when you’re not!
Take the uncertainty out of Web hosting and let GoDaddy.com
put service, performance and value back in. No matter which
hosting type or plan you choose, your site receives 24/7
maintenance and protection in our world-class data center.
Virtual Dedicated, Dedicated Server and unlimited plans also available.
Save 10% on web hosting - Enter code w3tenoff at checkout
 |
|
Get Your Diploma!
W3Schools' Online Certification Program is the perfect solution for busy
professionals who need to balance work, family, and career building.
The HTML Certificate is for developers who want to document their knowledge of HTML, XHTML, and CSS.
The JavaScript Certificate is for developers who want to document their knowledge of JavaScript and the HTML DOM.
The ASP Certificate is for developers who want to document their knowledge of ASP, SQL, and ADO.
|
|