简体   繁体   中英

Is ASP.NET OnClick attribute JavaScript?

For example:

<asp:Button id="Button1"
               Text="Click here for greeting..."
               OnClick="GreetingBtn_Click" 
               runat="server"/>

so my questions is:

  1. Is OnClick a javascript event on client side? if yes, does it mean that asp.net will add javascript code to the page then send the page back to browser?

  2. Sine javascript is case sensitivity, so "OnClick" should be "onclick"?

If you look there you'll see that this event will be executed on the server side. But ASP.NET will also generate code on client side something like this:

onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(...

so click on the button will produces postback to the server

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM