How to: Add Button Web Server Controls to a Web Forms Page

Web server controls make it easy for you to add different types of buttons to your Web Forms page. There are three types of button Web-server controls: Button, LinkButton, and ImageButton. For more information, see Button Web Server Controls Overview.

Adding an ImageButton control to a page is a little more involved than working with other button types. For details, see How to: Add ImageButton Web Server Controls to a Web Forms Page.

To add a button Web server control to a Web Forms page

  1. Add an<asp:Button>or <asp:LinkButton> element to the page. For syntax, see Button Web Server Control Declarative Syntax.

  2. Set the caption by setting the control's Text property.

Defining an Access Key

To make it easier for users to click a button, you can define an access key for the button. Users can then simultaneously press the ALT key and the access key to click the button.

NoteNote

Access keys are not supported in all browsers.

To define the access key for a button

  • Set the AccessKey property to a single letter or number. For example, to make the access-key combination ALT+B, specify B as the value of the AccessKey property.

    NoteNote

    In Windows applications, access keys are typically indicated on a button by an underlined character. This marking is not available for button Web server controls due to restrictions in HTML. If you want to be able to display the access key for a button, you can use the HtmlButton control.

See Also

Reference

Button Web Server Controls Overview