ASP.NET: OnClientClick
What's the point of the OnClientClick
attribute for an ASP.NET control? Doesn't it simply generate开发者_JS百科 an onclick
attribute for the HTML element?
Yes, it does just generate the client-side onclick attribute.
It is there to distinguish it from OnClick attribute, which generates the server-side click event.
yes
http://www.w3schools.com/aspnet/prop_webcontrol_button_onclientclick.asp
OnClick property is used to set server side Click event. So OnClientClick property is used to set client side OnClick attribute.
<!-- Calls btn_Click server side click event -->
<asp:Button runat="server" ID="btn" OnClick="btn_Click" />
<!-- Calls client side click event -->
<asp:Button runat="server" ID="btn"
OnClientClick="alert('client side click event.')" />
精彩评论