Create a Series of Wizard Pages to Add a Record
In order to create a wizard where one transaction spans data gathered on multiple web pages, you will need to write custom code. This custom code saves information gathered in the first page in the session instead of the database.

March 1, 2006
Iron Speed Designer V3.2

Introduction
Creating a wizard – a series of web pages that create or update a single database record – is fairly easy to do in Iron Speed Designer.

Let’s say you have an Add Customer function that gathers information about a new customer using two pages:

  • Add Customer page, for collecting and updating basic customer information.

  • Add Credit Card information page, for collecting and updating the customer’s credit card information.
By default, Iron Speed Designer creates applications where the transaction boundary is page-based – a normal .NET practice. So any information gathered is committed to the database for each page. In order to create a wizard where one transaction spans data gathered on multiple web pages, you will need to write custom code. This custom code saves information gathered in the first page in the session instead of the database. The custom code then saves the combined information to the database on the second page of the wizard. This is fairly easy to accomplish.
Step-by-Step
On the Add Customer page (first page in the wizard):

Step 1: Drag and drop an Add Record panel from the tool box onto your web page if one does not already exist. (You can also let the Application Wizard create an Add Record page with appropriate fields.) Delete the Save and Cancel buttons since we won’t need to save any data to the database in the first step of our wizard.

Step 2: Drag and drop a button from the tool box within the Add Record panel. Set the button text to “Next”.

Step 3: Double click the “Next” button to display the Properties dialog box for the button. On the Bindings tab, set these properties:

Property Setting
Button Command Send custom command
Validate page data before saving

 

Checked

This ensures the data on the first page will be validated before the second page is displayed.

Enter a new command name NextStep
 
Select a control CustomersRecordControl
Action after command

 

Go to a specific URL

Specify the path of the second page as the URL.

Step 4: Override the OnApplicationEvent() method in the RecordControl class in the first page. Handle the command for the button as shown below. In this function, store the data values in session variables. For example, if you have a field called FirstName on the page then you could store the value as follows.

Visual Basic .NET:

System.Web.HttpContext.Current.Session(“MyFirstname”) = Me.FirstName.Text

C#:

System.Web.HttpContext.Current.Session[“MyFirstname”] = this.FirstName.Text;

Similarly, retrieve the values of all the other fields and store them in their respective session variables.

Visual Basic .NET:

Public Overrides Sub OnApplicationEvent(ByVal args As BaseClasses.ApplicationEventArgs)
   If args.CustomEventName = "NextStep" Then

      ' here you will have to store the values in the session variables.

      System.Web.HttpContext.Current.Session(“MyFirstname”) = Me.FirstName.Text

      ' Store other field values here in the session.

   End If
   ' Make sure to call the underlying OnApplicationEvent to handle
   ' all other events.
   MyBase.OnApplicationEvent(args)
End Sub

On the Add Credit Card Information page (the second or last page in the wizard):

Step 1: Drag and drop an Add Record panel. (You can also let the Application Wizard create an Add Record page with appropriate fields.) Configure it to the table and display the other fields.

Step 2: Override the PostGetUIData() event in the record control class.

When the user clicks a button to save the data on the page, the data must first be extracted from the user interface controls and copied into a database record so it can be saved into the database. PostGetUIData() is triggered after the data is extracted from the user interface controls into the database record. All the data validation is complete before this event is triggered.

Step 3: Retrieve the values from the session variables that were stored in earlier pages and set those fields in this method.

Protected Overrides Sub OnPostGetUIData(ByVal e As System.EventArgs)
   ' Retrieve the current record, and append the additional values
   ' Pass True to GetRecord because we want to modify the fields.
   Dim myrec As CustomersRecord = Me.GetRecord(True)

   myrec.FirstName = System.Web.HttpContext.Current.Session(“MyFirstname”).ToString

   ' Similarly set values for all the other fields.

   ' The record will be saved as part of the normal page processing.

End Sub

To retrieve a session variable in C#, you can use:

System.Web.HttpContext.Current.Session[“MyVariable”];

If you have more than two pages in the wizard, all pages except the last one will be similar to the first page described above. They will contain a Next button that is handled in the OnApplicationEvent to save the values in session variables.

The last page collects all the values from the session variables and adds them to the record. By default, the Save button in the last page will point to the previous page. In this case, you might want to modify the properties of the Save button to point to a Show Table page instead.

Step 4: Finally, build and run the application.

About the Author
Alan S. Fisher
Co-Founder and Chairman of Iron Speed, Inc.

Mr. Fisher was a General Partner at Outlook Ventures, Inc., a venture capital company prior to co-founding Iron Speed, Inc. He co-founded Onsale, Inc. (now Egghead.com) and was its Chief Technology Officer from July 1994 to December 1999. He also Co-founded and was President of Software Partners, Inc, a developer and publisher of software products from August 1988 to July 1994. From April 1984 to August 1988, Mr. Fisher served as Technical Marketing Manager and Product Development Manager for Teknowledge, Inc., a developer of artificial intelligence software products. From June 1981 to April 1984, he served as a member of the technical staff for AT&T Bell Laboratories. Mr. Fisher serves on the Board of Directors of Infodata Systems Inc. (NASDAQ:INFD) an e-business consulting services company; He formerly served on the board of a number of companies including Onsale, Inc. (later Egghead.com and now Amazon.com), and FatBrain, Inc. an Internet retailer of technical and professional books.

Mr. Fisher received his B.S. in Electrical Engineering from the University of Missouri and received his M.S. in Electrical Engineering from Stanford University.



  Privacy Statement