ASP.NET Button control
Definition and usage
The Button control is used to display buttons. Buttons can be submit buttons or command buttons. 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 actions 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 actions to be executed when the command button is clicked.
Properties
Properties | 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 | Command related commands. | 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 to which data is sent 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 | 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 | When the Button control returns to the server, which control group that the Button belongs to triggered validation. | 2.0 |
Web controleer standaard eigenschappen
AccessKey, Attributes, BackColor, BorderColor, BorderStyle, BorderWidth, CssClass, Ingeschakeld, Lettertype, EnableTheming, Voorgrondkleur, Hoogte, IsIngeschakeld, SkinID, Stijl, TabIndex, ToolTip, Breedte
Voor een volledige beschrijving, bezoek Web controleer standaard eigenschappen.
Controleer standaard eigenschappen
AppRelativeTemplateSourceDirectory, BindingContainer, ClientID, Controls, EnableTheming, EnableViewState, ID, NamingContainer, Page, Parent, Site, TemplateControl, TemplateSourceDirectory, UniqueID, Zichtbaar
Voor een volledige beschrijving, bezoekControleer standaard eigenschappen.
Voorbeeld
- Button
- In dit voorbeeld hebben we een submit Button controle in het .aspx-bestand gedeclareerd. Vervolgens hebben we een eventhandler gecreëerd die de tekst op de knop kan wijzigen bij het optreden van een Click-gebeurtenis.
- Button 2
- In dit voorbeeld hebben we een submit Button controle in het .aspx-bestand gedeclareerd. Vervolgens hebben we een eventhandler gecreëerd die de tekst en het stijl van de knop kan wijzigen bij het optreden van een Click-gebeurtenis.