Onclick not added until after Postback

Posted by Morph on Stack Overflow See other posts from Stack Overflow or by Morph
Published on 2009-09-09T09:50:03Z Indexed on 2010/04/22 9:03 UTC
Read the original article Hit count: 162

Filed under:
|

I have the following:

<asp:Button id="SubmitButton" Text="Submit" runat="server" OnClientClick="Do();"  
     OnClick="SubmitButton_Click"/>

When the page is first rendered, I go to the view source in my browser and see that the onclick="Do();" is not added to my submit button tag. But when I do a post back, and do the view source again, the onclick is added to the submit.

Why would the onclick not be there on the first request?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about JavaScript