Wednesday, August 27, 2008

The Button Control[Common Web Server Controls]

The Button Control

1.The Button control displays a push button on the Web page that the user can click to trigger a PostBack to the Web server. A Button can be either a submit (default) button or a command button.

A submit button does not have its CommandName property set and simply performs a PostBack to the server. You provide an event handler for the Click event to control the actions performed when the user clicks the submit button.
You can use a Button as a command button by assigning a command name, such as ChangeChannel or FastFoward, to the CommandName property. Using the Command-Name property allows you to create multiple Button controls on a Web page; you can programmatically determine which button is clicked in the event handler for the Command
event. You can also use the CommandArgument property to provide additional information about the command to perform, such as ChannelUp, ChannelDown, x2 (FastForward x 2), or x3 (FastForward x 3). Simply provide an event handler for the Command event to control the actions performed when a command button is clicked.

2.The Button control also contains a CausesValidation property that is set to true by default, which causes page validation to be performed when a Button control is clicked. Set the CausesValidation property to false when you want a button to bypass validation. Reset and help buttons are examples of buttons that typically bypass validation.

No comments: