Web Server Controls->ASP.NET Button Control
2007-03-27 08:47
591 查看
Definition and Usage
The Button control is used to display a push button. The push button may be a submit button or a command button. By default, this control is a submit button.A submit button does not have a command name and it posts the Web page back to the server when it is clicked. It is possible to write an event handler to control the actions performed when the submit button is clicked.
A command button has a command name and allows you to create multiple Button controls on a page. It is possible to write an event handler to control the actions performed when the command button is clicked.
Properties
Property | Description |
---|---|
CausesValidation | By default, a page is validated when a Button control is clicked. To prevent a page from being validated when clicking on a Button control, set this property to "false" |
CommandArgument | Additional information about the command to perform |
CommandName | The command associated with the Command event |
id | A unique id for the control |
OnClick | The name of the function to be executed when the button is clicked |
runat | Specifies that the control is a server control. Must be set to "server" |
Text | The text on the button |
Examples
ButtonASPX Source:
<script runat="server"> Sub submit(Source As Object, e As EventArgs) button1.Text="You clicked me!" End Sub </script> <html> <body> <form runat="server"> <asp:Button id="button1" Text="Click me!" runat="server" OnClick="submit" /> </form> </body> </html> |
Output Result:
Button 2
ASPX Source:
<script runat="server"> Sub submit(Source As Object, e As EventArgs) button1.Style("background-color")="#0000ff" button1.Style("color")="#ffffff" button1.Style("width")="200px" button1.Style("cursor")="hand" button1.Style("font-family")="verdana" button1.Style("font-weight")="bold" button1.Style("font-size")="14pt" button1.Text="You clicked me!" End Sub </script> <html> <body> <form runat="server"> <asp:Button id="button1" Text="Click me!" runat="server" OnClick="submit" /> </form> </body> </html> |
Output Result:
IF you click the button ,it will shows :
相关文章推荐
- Web Server Controls->ASP.NET ImageButton Control
- Web Server Controls->ASP.NET RadioButton Control
- Web Server Controls->ASP.NET AdRotator Control
- Web Server Controls->ASP.NET HyperLink Control
- Web Server Controls->ASP.NET TableRow Control
- Web Server Controls->ASP.NET Panel Control
- Web Server Controls->ASP.NET Table Control
- Web Server Controls->ASP.NET Image Control
- Web Server Controls->ASP.NET PlaceHolder Control
- Web server Controls->ASP.NET TextBox Control
- Web Server Controls->ASP.NET CheckBox Control
- Web Server Controls->ASP.NET Label Control
- Web Server Controls->ASP.NET LinkButton Control
- Web Server Controls->ASP.NET RadioButtonList Control
- Web Server Controls->ASP.NET ListBox Control
- Web Server Controls->ASP.NET DropDownList Control
- Web Server Controls->ASP.NET Literal Control
- Web Server Controls->ASP.NET TableCell Control
- Web Server Controls->ASP.NET XML Control
- ASP.NET Web Server Control 开发系列