OnClick this keyword, it is the client JS script keyword, but also asp.net server control in the control properties, the latter is actually onserverclick.
The difference is that the former occurs on the client and the browser completes the operation, which needs to be loopback to the server side and run by the server side.
If you are not a server-side control for code in generic HTML, you can use OnClick to define a client event. Onseverclick is the method the server-side script calls;.
, such as a button server control, can have both client and server-side onclick, in the order of first-client-server-side. But you need to be aware when defining:
<asp:button id= "cmdReturn2" on the page This OnClick in the runat= "server" onclick= "Returnfile" >Return</asp:Button>
defines the server-side event, because this is the control, Returnfile is a method that is defined in code.
If you need to have the onclick in client JS at the same time, you need to pass the BUTTON.ATTRIBUTES.ADD in the code (" OnClick "," Return checkmailbox (); ") To join, is to return the result of the Checkmailbox () to the OnClick event, note ("onclick", "return Checkmailbox") and ("onclick", "return Checkmailbox ") is different, the former if the return False,onclick event will not execute, the latter regardless of return any value to carry on again.
actually asp.net encapsulates a lot of things, and it makes it easy for a lot of new people to figure out what's going on, like the server-side click event mentioned above. In fact, this is not a real event, just let you have the feeling of the event, the essence is actually a post submission form, if Microsoft changed server-side onclick event name for onsubmit may be better understood.