I'm learning asp.net. I have question about example buttons
I can use two types of button.
<input id="Button1" type="button" value="button" />
or
<asp:Button ID="Button3" runat="server" Text="Button" />
What are the main开发者_如何转开发 differences between the two?
One is a server control (the asp button) that when rendered on the page includes javascript that handles the postback logic, as well as being exposed to your code-behinds as a control you can address by its ID. The Html control is platform agnostic, and is rendered by your browser as just a button. That button will raise click events but will not POST your form.
Each click will make a round trip to server, which should not occur everytime. HTML Button is much lighter and should be used to make client - logic like client validation, run client script,etc....
ASP button will makes a POST everytime you click, html button do not.
精彩评论