2

What's the point of the OnClientClick attribute for an ASP.NET control? Doesn't it simply generate an onclick attribute for the HTML element?

3 Answers 3

5

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.

Sign up to request clarification or add additional context in comments.

Comments

2

yes

http://www.w3schools.com/aspnet/prop_webcontrol_button_onclientclick.asp

Comments

2

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.')" />

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.