Reputation:
I am using a WizardControl in .NET 2.0. On the first Step (which is set to StepType="Start") when the next button is clicked, I run server-side validation code. But, no matter what I do it keeps going to the next step. Here is my code:
Protected Sub Wizard1_NextButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.NextButtonClick
Dim oUser As New BE.User
Select Case Wizard1.ActiveStepIndex
Case 0
If Membership.FindUsersByName(UserName.Text).Count = 0 Then
oUser.UserName = UserName.Text
oUser.Password = Password.Text
oUser.Email = Email.Text
Wizard1.ActiveStepIndex = 1
Else
Wizard1.ActiveStepIndex = 0
ErrorMessage.Text = "user name already in use"
End If
Case 1
Case 2
End Select
End Sub
Upvotes: 1
Views: 3405
Reputation: 28530
As others have mentioned, you can use the Cancel
property of the WizardNavigationEventArgs
. Here's your code updated to reflect that:
Protected Sub Wizard1_NextButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.NextButtonClick
Dim oUser As New BE.User
Select Case Wizard1.ActiveStepIndex
Case 0
If Membership.FindUsersByName(UserName.Text).Count = 0 Then
oUser.UserName = UserName.Text
oUser.Password = Password.Text
oUser.Email = Email.Text
Wizard1.ActiveStepIndex = 1
Else
Wizard1.ActiveStepIndex = 0
ErrorMessage.Text = "user name already in use"
' Set the Cancel property to True here
e.Cancel = True
End If
Case 1
Case 2
End Select
End Sub
Upvotes: 1
Reputation: 41
You can write e.Cancel=true
if you are working in any wizard event. Here "e" is an alias for WizardNavigationEventArgs
Upvotes: 4
Reputation:
The Wizard control's NextButtonClick
event has a
"WizardNavigationEventArgs
" parameter that contains a "Cancel"
property
help to cancel the current next navigation operation.
courtesy of
Steven Cheng Microsoft Online Support
Upvotes: 1