Controls You Can Use on Web Forms ASP.NET Standard Controls Button Controls
Buttons on a Web Forms page allow users to indicate that they are finished with the form or want to perform a specific command. Web server controls include three kinds of buttons that allow you to select buttons with different appearances.
You can create these types of Web server control buttons:
Button |
Presents a standard command button, rendered as an HTML submit button. |
LinkButton |
Renders as a hyperlink in the page. However, it contains client-side script that causes the form to be posted back to the server. ( You can create a true hyperlink using the HyperLink Control . ) |
ImageButton |
Allows you to specify a graphic as a button. This is useful for presenting a rich button appearance. ImageButton controls also pinpoint where in the graphic a user has clicked, which allows you to use the button as an image map. |
All three button types cause a form to be submitted when the user clicks them. This causes the page to be processed and any pending events to be raised in server-based code. The buttons can also raise their own Click events that you can write event-handling methods for.
Button Controls are often used in other controls, such as in the DataList control, DataGrid Control, and Repeater Control list controls. When they are, you generally respond to their events differently than when they were standing alone in a form. When users clicks a button in a container control, the event message is bubbled to the container control, where it raises a container-specific event. For example, in the DataList control, a button often raises the ItemCommand event ( rather than a Click event ) .
Because the list Web server controls can contain many different buttons, you can specify an argument to pass along with the event when the event is bubbled to the container control. You can then test for this argument to see which button was clicked.
You can bind the ASP.NET server button controls to a data source in order to control their property settings dynamically. For example, you can set the button’s Text property via data binding.