Whidbey’s New Wizard Control Adds Navigational Power

Whidbey’s New Wizard Control Adds Navigational Power

SP.NET v2.0 adds many new concepts and controls beyond those shipped in version 1.1. One of these is the Wizard control, which can simplify your life when you need to implement a “step by step” interface style to capture data. The Wizard provides built-in navigation capability that lets you make logical field groupings for each step in a single aspx page where the process would normally require multiple steps (and complicated logic or multiple pages). The Wizard control uses ViewState (.NET’s built-in method for maintaining control values between requests) to handle the data each time the Wizard posts data back to the server, thus reducing your work. Further, you can use customizable templates to tailor the display for each step of the wizard.

Capturing Customer Information
The sample Wizard application captures customer information details such as name, gender, address, and preferred notifications. Typically, the process would require a long input form or several pages. Figure 1 shows a database-table view of the fields the application should capture.

Add Template Definitions
The HeaderTemplate, StartNavigationTemplate, FinishNavigationTemplate, SideBarTemplate, and StepNavigationTemplate help you configure the Header, Start, Finish, Sidebar, and intermediate steps of the Wizard respectively. You add these templates within the section.

The HeaderTemplate is the simplest. To use it, add the HeaderTemplate definition shown in Listing 2.

Listing 2 contains nothing remarkable, just HTML declarations for a table with header text and an image. The header content will appear on each screen except the screen where steptype is Complete. Figure 6 shows how adding a header template changes the Start screen display. Remember to copy any image files to the image folder for your project, which you’ll find under the root folder.

Handling Validation and Events
To validate user inputs, you use the new ValidationGroup property. The property helps you validate control values within a particular grouping. Controls that inherit from BaseValidator expose ValidationGroup as a string property. To group controls, assign the same string value to ValidationGroup for all controls you want to place in that group. Then, assign the same string value to the ValidationGroup property of the Validation controls (such as RequiredFieldValidator, etc) that you’re using to validate the content, and to the control that posts the content?usually a button or link.

For example, the sample application declares RequiredFieldValidator validation controls, and associates them with the mandatory fields, and declares a CompareValidator to validate the birthdate entry. All the validation and field controls have the same ValidationGroup value?”customervalidate.” In addition, the Next and SideBar button controls ValidationGroup property have this value. Doing that ensures that all the controls associated with that ValidationGroup value get validated whenever the user clicks a sidebar link or the Next button.

You need to add some server side event handlers to handle the record insertion. The following code fragment associates the handlers with specific events.

   

I’ve used Trace statements in the sample code events to help you follow the event sequence. You can view the trace information by adding the trace=true directive to the page and then executing the application.

Table 3 describes the events used and a description stating when the event occurs and, where appropriate, how that event gets handled in the sample application.

Table 3. Wizard Events: The table contains a list and description of the Wizard events used in the sample application.

Event

Description

ActiveViewChanged

Fired for each step of wizard, since each step is a differentview. This occurs between the Begin Init and End init step, effectivelybefore the Init event executes.

Note: For the full server side code, refer tothe sample project that accompanies this article.

NextButtonClick

Fired when a user clicks the “NextButton” in any step.

Action: In the sample, theevent calls a “ProcessHeader” method. This method gets a collectionof all the WizardSteps as a WizardStepCollection using the WizardSteps (seeListing 1 for definitions) property of the wizard. Use the CurrentStepIndex propertyof the WizardNavigationEventArgs to get the currentstep from thiscollection. You can also use the wizard’s ActiveStep property for the same purpose.Finally, set the label control in the header to display contentlike “Step 1 of 2…” etc.

Note: Though direct reference to controlidentifiers is possible, as examples there are instances in thesample using FindControl to get reference to control.

FinishButtonClick

Fired when a user clicks the “FinishButton” in the WizardStep (steptype=”Finish”).

Action: Iterate through each WizardStep of the WizardStepCollection andcollect the user input from the controls. In case the validationfails for mandatory check, use wzCustomer.MoveTo(step) to move backto a specific step. If validation succeeds update the database.

SideBarClick

Fired on click of sidebar links. In the sample calls the method”ProcessHeader”.

PreviousButtonclick

Fired on click of Previous buttons. Not implemented in this sample.

Commonly Used Wizard Methods and Properties
You may need to identify and process each step as users complete a Wizard. The WizardNavigationEventArgs parameter sent by the control for each event provides properties you can use to identify the specific step involved, such as the NextStepIndex and CurrentStepIndex properties. Use the WizardStepCollection property to access individual steps and their contents. You can also cause the Wizard to move to a particular step using the MoveTo method. Table 4 describes the some of the most commonly used Wizard methods and properties you’ll need.

Table 4. Common Wizard Properties and Methods: The table shows the most common properties and methods of the Wizard control.

Property/Method

Description

ActiveStep

Used to get the currentstep of the Wizard.

WizardSteps

WizardStepCollection?Gives you the collection of all Steps.You can pass the index to the collection to get a particular step.For example: WizardStepCollection StepsCollection= wzCustomer. WizardSteps;WizardStep step = StepsCollection[1];

FinishStepButtonText, NextStepButtonText, PreviousStepButtonText,etc

These are used to set the display text values of the correspondingbuttons. There are properties for each buttons available in wizard.

MoveTo(step)

A very important method that moves the wizard to the step mentioned.

SideBarStyle, NavigationButtonStyle, etc

TableItemStyles to configure styles for respective controls.

At this point, you’ve completed the Customer information sample. Run the sample to investigate the flow and experiment with the Wizard. If you want to actually post the data to a database, run the .sql file that accompanies the sample code.

You can simplify the process of developing complex multi-page user input forms using the innovative Wizard control. The Wizard handles the multi-page scenario within a single page, and provides templates for customizing the form pages’ appearance. The Wizard navigation model supports skipping steps or jumping directly to a specific step, while the event model provides fine-grained control over the form data, which is critical in these scenarios.

devx-admin

devx-admin

Share the Post:
Chinese 5G Limitation

Germany Considers Limiting Chinese 5G Tech

A recent report has put forth the possibility that Germany’s Federal Ministry of the Interior and Community may consider limiting the use of Chinese 5G

Modern Warfare

The Barak Tank is Transforming Modern Warfare

The Barak tank is a groundbreaking addition to the Israeli Defense Forces’ arsenal, significantly enhancing their combat capabilities. This AI-powered military vehicle is expected to

AI Cheating Growth

AI Plagiarism Challenges Shake Academic Integrity

As generative AI technologies like ChatGPT become increasingly prevalent among students and raise concerns about widespread cheating, prominent universities have halted their use of AI

US Commitment

US Approves Sustainable Battery Research

The US Department of Energy has revealed a $325 million commitment in the research of innovative battery types, designed to enable solar and wind power

Netanyahu Musk AI

Netanyahu and Musk Discuss AI Future

On September 22, 2023, Israeli Prime Minister Benjamin Netanyahu met with entrepreneur Elon Musk in San Francisco prior to attending the United Nations. In a

Chinese 5G Limitation

Germany Considers Limiting Chinese 5G Tech

A recent report has put forth the possibility that Germany’s Federal Ministry of the Interior and Community may consider limiting the use of Chinese 5G technology by local network providers

Modern Warfare

The Barak Tank is Transforming Modern Warfare

The Barak tank is a groundbreaking addition to the Israeli Defense Forces’ arsenal, significantly enhancing their combat capabilities. This AI-powered military vehicle is expected to transform the way modern warfare

AI Cheating Growth

AI Plagiarism Challenges Shake Academic Integrity

As generative AI technologies like ChatGPT become increasingly prevalent among students and raise concerns about widespread cheating, prominent universities have halted their use of AI detection software, such as Turnitin’s

US Commitment

US Approves Sustainable Battery Research

The US Department of Energy has revealed a $325 million commitment in the research of innovative battery types, designed to enable solar and wind power as continuous, 24-hour energy sources.

Netanyahu Musk AI

Netanyahu and Musk Discuss AI Future

On September 22, 2023, Israeli Prime Minister Benjamin Netanyahu met with entrepreneur Elon Musk in San Francisco prior to attending the United Nations. In a live-streamed discussion, Netanyahu lauded Musk

Urban Gardening

Creating Thriving Cities Through Urban Gardening

The rising popularity of urban gardening is receiving increased recognition for its numerous advantages, as demonstrated in a recent study featured in the Environmental Research Letters journal. Carried out by

What You Need to Know About Cloud Security Strategies

What You Need to Know About Cloud Security Strategies

Today, many businesses are adopting cloud computing services. As a result, it’s important to recognize that security measures for data in the cloud are different from those in traditional on-premises

Romanian Energy Security

Eastern Europe is Achieving Energy Security

Canada and Romania have solidified their commitment to energy security and independence from Russian energy exports by signing a $3-billion export development agreement. The deal is centered on constructing two

Seamless Integration

Unlocking Seamless Smart Home Integration

The vision of an intelligently organized and interconnected smart home that conserves time, energy, and resources has long been desired by many homeowners. However, this aspiration has often been hindered

New Algorithm

MicroAlgo’s Groundbreaking Algorithm

MicroAlgo Inc. has revealed the creation of a knowledge-augmented backtracking search algorithm, developed through extensive research in evolutionary computational techniques. The algorithm is designed to boost problem-solving effectiveness, precision, and

Poland Energy Future

Westinghouse Builds Polish Power Plant

Westinghouse Electric Company and Bechtel have come together to establish a formal partnership in order to design and construct Poland’s inaugural nuclear power plant at the Lubiatowo-Kopalino site in Pomerania.

EV Labor Market

EV Industry Hurting For Skilled Labor

The United Auto Workers strike has highlighted the anticipated change towards a future dominated by electric vehicles (EVs), a shift which numerous people think will result in job losses. However,

Soaring EV Quotas

Soaring EV Quotas Spark Battle Against Time

Automakers are still expected to meet stringent electric vehicle (EV) sales quotas, despite the delayed ban on new petrol and diesel cars. Starting January 2023, more than one-fifth of automobiles

Affordable Electric Revolution

Tesla Rivals Make Bold Moves

Tesla, a name synonymous with EVs, has consistently been at the forefront of the automotive industry’s electric revolution. The products that Elon Musk has developed are at the forefront because

Sunsets' Technique

Inside the Climate Battle: Make Sunsets’ Technique

On February 12, 2023, Luke Iseman and Andrew Song from the solar geoengineering firm Make Sunsets showcased their technique for injecting sulfur dioxide (SO₂) into the stratosphere as a means

AI Adherence Prediction

AI Algorithm Predicts Treatment Adherence

Swoop, a prominent consumer health data company, has unveiled a cutting-edge algorithm capable of predicting adherence to treatment in people with Multiple Sclerosis (MS) and other health conditions. Utilizing artificial

Personalized UX

Here’s Why You Need to Use JavaScript and Cookies

In today’s increasingly digital world, websites often rely on JavaScript and cookies to provide users with a more seamless and personalized browsing experience. These key components allow websites to display

Geoengineering Methods

Scientists Dimming the Sun: It’s a Good Thing

Scientists at the University of Bern have been exploring geoengineering methods that could potentially slow down the melting of the West Antarctic ice sheet by reducing sunlight exposure. Among these

why startups succeed

The Top Reasons Why Startups Succeed

Everyone hears the stories. Apple was started in a garage. Musk slept in a rented office space while he was creating PayPal with his brother. Facebook was coded by a

Bold Evolution

Intel’s Bold Comeback

Intel, a leading figure in the semiconductor industry, has underperformed in the stock market over the past five years, with shares dropping by 4% as opposed to the 176% return

Semiconductor market

Semiconductor Slump: Rebound on the Horizon

In recent years, the semiconductor sector has faced a slump due to decreasing PC and smartphone sales, especially in 2022 and 2023. Nonetheless, as 2024 approaches, the industry seems to

Elevated Content Deals

Elevate Your Content Creation with Amazing Deals

The latest Tech Deals cater to creators of different levels and budgets, featuring a variety of computer accessories and tools designed specifically for content creation. Enhance your technological setup with

Learn Web Security

An Easy Way to Learn Web Security

The Web Security Academy has recently introduced new educational courses designed to offer a comprehensible and straightforward journey through the intricate realm of web security. These carefully designed learning courses

©2023 Copyright DevX - All Rights Reserved. Registration or use of this site constitutes acceptance of our Terms of Service and Privacy Policy.

Sitemap