ASP.NET ButtonControl
Web Server Controls
Definition and Usage
The Button control is used to display a push button. The push button can be a submit button or a command button. By default, the control is a submit button.
Submit buttons do not have a command name; when clicked, they post the page back to the server. You can write event handlers to control the actions performed when the submit button is clicked.
Command buttons have a command name and allow you to create multiple button controls on the page. You can write event handlers to control the actions performed when the command button is clicked.
Properties
| Property | Description | .NET |
|---|---|---|
| CausesValidation | Specifies whether the page is validated when the Button is clicked. | 1.0 |
| CommandArgument | Specifies additional information about the command to execute. | 1.0 |
| CommandName | Specifies the command associated with the Command event. | 1.0 |
| OnClientClick | Specifies the name of the function to execute when the button is clicked. | 2.0 |
| PostBackUrl | Specifies the URL of the target page to send data to from the current page when the Button control is clicked. | 2.0 |
| runat | Specifies that the control is a server control. Must be set to "server". | 1.0 |
| Text | Specifies the text on the button. | 1.0 |
| UseSubmitBehavior | A value that specifies whether the button uses the browser's submit mechanism or ASP.NET's postback mechanism. | 2.0 |
| ValidationGroup | Specifies the control group that causes validation when the button posts back to the server. | 2.0 |
Web Control Standard Properties
For a full description, please visitWeb Control Standard Properties。
Control Standard Properties
For a full description, please visitControl Standard Properties。
Try it - Examples
Button
In this example, we declare a submit Button control in an .aspx file. Then we create an event handler that changes the text on the button when the Click event occurs.
Button 2
In this example, we declare a submit Button control in an .aspx file. Then we create an event handler that changes the text and style of the button when the Click event occurs.
Web Server Controls Other Extensions