ASP.NET Button Control
Web Server Controls
Definition and Usage
The Button control is used to display a push button. A push button can be a submit button or a command button. By default, this control is a submit button.
A submit button has no command name; when it is clicked, it posts the page back to the server. You can write event handlers to control the action executed when the submit button is clicked.
A command button has a command name and allows you to create multiple Button controls on the page. You can write event handlers to control the action executed when the command button is clicked.
property
| 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 be executed. | 1.0 |
| CommandName | Specifies the command associated with the Command event. | 1.0 |
| OnClientClick | Specifies the name of the function executed when the button is clicked. | 2.0 |
| PostBackUrl | Specifies the target page URL to which data is transferred 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 that when the button posts back to the server, the control group to which the button belongs triggers validation. | 2.0 |
Web Control Standard Properties
AccessKey, Attributes, BackColor, BorderColor, BorderStyle, BorderWidth, CssClass, Enabled, Font, EnableTheming, ForeColor, Height, IsEnabled, SkinID, Style, TabIndex, ToolTip, Width
For a complete description, please visit Web Control Standard Properties。
Web Control Standard Properties
AppRelativeTemplateSourceDirectory, BindingContainer, ClientID, Controls, EnableTheming, EnableViewState, ID, NamingContainer, Page, Parent, Site, TemplateControl, TemplateSourceDirectory, UniqueID, Visible
For a complete description, please visit Web Control Standard Properties。
Try it - Example
Button
In this example, we declare a submit Button control in the .aspx file. Then we create an event handler that can change the text on the button when the Click event occurs.
Button 2
In this example, we declare a submit Button control in the .aspx file. Then we create an event handler that can change the button's text and style when the Click event occurs.
Web Server Controls