A Demo of the Wizard Control in ASP.NET 2.0 - Writing Code for the Steps
(Page 4 of 6 )
When the page loads, Step 1 will be in view and you should make sure that Step 1 is showing in the design view before you browse the page. Here you will be entering the names and clicking the Next button. The names you enter remain in the textboxes. When you click the Next button, the wizard moves to Step 2.
In Step 2 you will click the calendar control to add a date which will remain in the textbox in Step 2. When you click on the Next button you will move to Step 3.
In Step 3 you gather up all the information, and when you click on the Finish button you will display it in Step 3's "View Area." The code for the logic followed by the steps is shown in the next paragraph.
Partial Class wiz
Inherits System.Web.UI.Page
Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) _
Handles Wizard1.FinishButtonClick
Label1.Visible = True
TextBox3.Visible = False
Label2.Visible = False
Label1.Text = "<font color='blue'>" + TextBox3.Text _
+ "</font>" + "<p></p>" + "<font color='green'>" + _
TextBox1.Text + " " + TextBox2.Text + "</font>" + _
"<br/>" + "Your last visit was on " + TextBox4.Text
End Sub
Protected Sub Wizard1_NextButtonClick(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) _
Handles Wizard1.NextButtonClick '[logic] if this logic is omitted
the Label1's text Label
would show up
'going from step 2 to three. If e.NextStepIndex = 2 Then
Label1.Visible = False
End If '[/logic] 'The textbox3 contents are carried forward
to finish
'but it's visibility is set to false TextBox3.Visible =
False 'must be false
TextBox3.Text = "We Cordially Welcome You Back"
End Sub
Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged
TextBox4.Text = Calendar1.SelectedDate.ToShortDateString
End Sub
End Class
A couple of annotations are in the code. The Label1.text after the Finish button is clicked collects all information and presents it. Textbox4 carries the date information from Step 2, while Textbox1 and Textbox2 carry the name information from Step1. If Textbox3 is not set to false in the Finish event, then Textbox3 will show through. The steps are indexed with 0 as the start index. Also note that the UI is represented by a partial class.
Next: A Display of the Wizard in Action >>
More ASP.NET Articles
More By Jayaram Krishnaswamy