|
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.
|