Buttons are controls that post the form back to the server, enabling server-side processing to commence. There are three types of button controls:
In addition to the properties, methods, and events inherited along with all the other ASP controls, all three button types have the following two events:
Raised when control is clicked and no command name is associated with the button (that is, no value has been assigned to the Button control’s CommandName property). The method is passed an argument of type EventArgs.
Raised when the control is clicked and a command name is associated with the button (that is, a command name has been assigned to the Button control’s CommandName property). The event is passed an argument of type CommandEventArgs, which has the following two members:
The name of the command
An optional argument for the command
The code in Example 5-5 and Example 5-6 creates a web page containing three buttons, one of each type. Each button performs the same task: transferring control to another web page. Example 5-5 shows the C# code, and Example 5-6 shows the same code in VB.NET.
In order for the code in Example 5-5 and Example 5-6 to work correctly, you must have a target web
page to link to. This can be any valid
.aspx file. In
these examples, the target page is hard-coded as
TargetPage.aspx, located in the
ProgAspNet virtual directory. In addition, you will need ...