ASP.NET Button Control
Definition and Usage
The Button control is used to display buttons. The button can be a submit button or a command button. By default, the control is a submit button.
The submit button does not have a command name, and when it is clicked, it will return the web page to the server. You can write event handlers to control the action to be executed when the submit button is clicked.
The 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 to be 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 | Additional information about the command to be executed. | 1.0 |
CommandName | The command related to Command. | 1.0 |
OnClientClick | The name of the function to be executed when the button is clicked. | 2.0 |
PostBackUrl | The target page URL from the current page that sends data when the Button control is clicked. | 2.0 |
runat | Specifies that the control is a server control. It must be set to "server". | 1.0 |
Text | The text on the button. | 1.0 |
UseSubmitBehavior | A value indicating whether the Button control uses the browser's submission mechanism or the ASP.NET postback mechanism. | 2.0 |
ValidationGroup | Which control group of the Button control triggered validation when the Button control returns to the server. | 2.0 |
Standard Properties of Web Controls
AccessKey, Attributes, BackColor, BorderColor, BorderStyle, BorderWidth, CssClass, Enabled, Font, EnableTheming, ForeColor, Height, IsEnabled SkinID, Style, TabIndex, ToolTip, Width
For a full description, please visit Standard Properties of Web Controls.
Standard Properties of Controls
AppRelativeTemplateSourceDirectory, BindingContainer, ClientID, Controls EnableTheming, EnableViewState, ID, NamingContainer, Page, Parent, Site TemplateControl, TemplateSourceDirectory, UniqueID, Visible
For a full description, please visitStandard Properties of Controls.
Example
- Button
- In this example, we declared a submit Button control in the .aspx file. Then we created an event handler that can change the text on the button when the Click event occurs.
- Button 2
- In this example, we declared a submit Button control in the .aspx file. Then we created an event handler that can change the text and style of the button when the Click event occurs.