Online Book Reader

Home Category

Programming Microsoft ASP.NET 4 - Dino Esposito [212]

By Root 5701 0
containing all the WizardStep objects defined in the control.

A wizard in action is fully represented by its collection of step views and buttons. In particular, you’ll recognize the following buttons: StartNext, StepNext, StepPrevious, FinishComplete, FinishPrevious, and Cancel. Each button is characterized by properties to get and set the button’s image URL, caption, type, and destination URL after a click. The name of a property is the name of the button followed by a suffix. The available suffixes are listed in Table 9-8.

Table 9-8. Suffix of Button Properties

Suffix

Description

ButtonImageUrl

Gets and sets the URL of the image used to render the button

ButtonText

Gets and sets the text for the button

ButtonType

Gets and sets the type of the button: push button, image, or link button

DestinationPageUrl

Gets and sets the URL to jump to once the button is clicked

Note that names in Table 9-8 do not correspond to real property names. You have the four properties in this table for each distinct type of wizard button. The real name is composed by the name of the button followed by any of the suffixes—for example, CancelButtonText, FinishCompleteDestinationPageUrl, and so on.

The Wizard control also supplies a few interesting methods—for example, GetHistory, which is defined as follows:

public ICollection GetHistory()

GetHistory returns a collection of WizardStepBase objects. The order of the items is determined by the order in which the wizard’s pages were accessed by the user. The first object returned—the one with an index of 0—is the currently selected wizard step. The second object represents the view before the current one, and so on.

The second method, MoveTo, is used to move to a particular wizard step. The method’s prototype is described here:

public void MoveTo(WizardStepBase step)

The method requires you to pass a WizardStepBase object, which can be problematic. However, the method is a simple wrapper around the setter of the ActiveStepIndex property. If you want to jump to a particular step and not hold an instance of the corresponding WizardStep object, setting ActiveStepIndex is just as effective.

Table 9-9 lists the key events in the life of a Wizard control in an ASP.NET page.

Table 9-9. Events of the Wizard Control

Event

Description

ActiveViewChanged

Raised when the active step changes

CancelButtonClick

Raised when the Cancel button is clicked

FinishButtonClick

Raised when the Finish Complete button is clicked

NextButtonClick

Raised when any Next button is clicked

PreviousButtonClick

Raised when any Previous button is clicked

SideBarButtonClick

Raised when a button on the sidebar is clicked

As you can see, there’s a common click event for all Next and Previous buttons you can find on your way. A Next button can be found on the Start page as well as on all step pages. Likewise, a Previous button can be located on the Finish page too. Whenever a Next button is clicked, the page receives a NextButtonClick event; whenever a Previous button is clicked, the control raises a PreviousButtonClick event.

Adding Steps to a Wizard


A WizardStep object represents one of the child views that the wizard can display. The WizardStep class ultimately derives from View and adds just a few public properties to it. A View object represents a control that acts as a container for a group of controls. A view is hosted within a MultiView control. To create its output, the wizard makes internal use of a MultiView control. However, the wizard is not derived from the MultiView class.

You define the views of a wizard through distinct instances of the WizardStep class, all grouped under the tag. The tag corresponds to the WizardSteps collection property exposed by the Wizard control:

...

...

Each wizard step is characterized by a title and a type. The Title property provides a brief description of the view. This information

Return Main Page Previous Page Next Page

®Online Book Reader