Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

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

Community Additions

ADD
Show:
© 2015 Microsoft