A
Andy B.
I have a Wizard control inside of a web user control. The steps are these:
0=Start (form to add/edit headlines), 1= confirmation step (make sure what
you entered is true) and 2= complete step(show the results of the database
actions). Step index 2 (result of actions step) has an ok button on it. If
there were errors, it will display them in this step and the ok button will
return the user to the form to make changes. If there are no errors, it
displays a success message and the ok button returns the user to the home
page. This is all for a DNN 4.9.4 module.
In the Wizard.FinishButton_Click event, the code determines if it should run
an insert or an update and does what is required of it. If the requested
database action fails, it is sent to the catch block where the errors are
shown on the actions result page of the wizard. My problem is that the
variable HasEditFailed is skipped in the code and I can't figure out why.
Everything works except this. Here is the relevant code.
private HasEditFailed as boolean = false
Protected Sub EditHeadlineWizard_FinishButtonClick(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles
EditHeadlineWizard.FinishButtonClick
Try
Dim PortalSecurity As New PortalSecurity
Dim HeadlinesController As New HeadlinesController
Dim HeadlinesInfo As New HeadlinesInfo
HeadlinesInfo.Content = PortalSecurity.InputFilter(ContentTextBox.Text,
Security.PortalSecurity.FilterFlag.NoScripting And
Security.PortalSecurity.FilterFlag.NoSQL)
HeadlinesInfo.CreatedByUser = Me.UserId
HeadlinesInfo.DateCreated = Date.Now
HeadlinesInfo.Description =
PortalSecurity.InputFilter(Regex.Replace(DescriptionTextBox.Text, "<[^>]*>",
String.Empty), Security.PortalSecurity.FilterFlag.NoMarkup)
HeadlinesInfo.ExpirationDate = CType(ExpirationDateTextBox.Text, Date)
HeadlinesInfo.ItemID = ItemId
HeadlinesInfo.ModuleID = ModuleId
HeadlinesInfo.Title =
PortalSecurity.InputFilter(Regex.Replace(TitleTextBox.Text, "<[^>]*>",
String.Empty), Security.PortalSecurity.FilterFlag.NoMarkup)
If Common.Utilities.Null.IsNull(ItemId) Then
'Add the new headline.
HeadlinesController.InsertHeadline(HeadlinesInfo)
CompletedTextLabel.Text = "The headline '" + HeadlinesInfo.Title + "' Was
saved to the database."
HasEditFailed = False
Else
'Update the headline
HeadlinesController.UpdateHeadline(HeadlinesInfo)
CompletedTextLabel.Text = "The headline titled '" + HeadlinesInfo.Title + "'
has been updated and saved to the database."
HasEditFailed = False
End If
Catch ex As SqlException
Dim ErrorsList As New StringBuilder
ErrorsList.Append("The headline could not be saved for the following
reasons. Review the list and make sure your entries are correct. When you
are finished reviewing the list, press the OK button to return to the edit
headline form to re-enter your values.")
ErrorsList.Append("<br /><br />")
ErrorsList.Append("<ul>")
For Each ActualError As SqlError In ex.Errors
ErrorsList.Append("<li>" + ActualError.Message + "</li>")
Next
ErrorsList.Append("</ul>")
CompletedTextLabel.Text = ErrorsList.ToString()
EditHeadlineWizard.ActiveStepIndex = 2
'The line below is skipped all the time.
HasEditFailed = True
End Try
End Sub
Protected Sub OKButton_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles OKButton.Click
If HasEditFailed = False Then
Response.Redirect(NavigateURL(), True)
Else
EditHeadlineWizard.ActiveStepIndex = 0
End If
End Sub
0=Start (form to add/edit headlines), 1= confirmation step (make sure what
you entered is true) and 2= complete step(show the results of the database
actions). Step index 2 (result of actions step) has an ok button on it. If
there were errors, it will display them in this step and the ok button will
return the user to the form to make changes. If there are no errors, it
displays a success message and the ok button returns the user to the home
page. This is all for a DNN 4.9.4 module.
In the Wizard.FinishButton_Click event, the code determines if it should run
an insert or an update and does what is required of it. If the requested
database action fails, it is sent to the catch block where the errors are
shown on the actions result page of the wizard. My problem is that the
variable HasEditFailed is skipped in the code and I can't figure out why.
Everything works except this. Here is the relevant code.
private HasEditFailed as boolean = false
Protected Sub EditHeadlineWizard_FinishButtonClick(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles
EditHeadlineWizard.FinishButtonClick
Try
Dim PortalSecurity As New PortalSecurity
Dim HeadlinesController As New HeadlinesController
Dim HeadlinesInfo As New HeadlinesInfo
HeadlinesInfo.Content = PortalSecurity.InputFilter(ContentTextBox.Text,
Security.PortalSecurity.FilterFlag.NoScripting And
Security.PortalSecurity.FilterFlag.NoSQL)
HeadlinesInfo.CreatedByUser = Me.UserId
HeadlinesInfo.DateCreated = Date.Now
HeadlinesInfo.Description =
PortalSecurity.InputFilter(Regex.Replace(DescriptionTextBox.Text, "<[^>]*>",
String.Empty), Security.PortalSecurity.FilterFlag.NoMarkup)
HeadlinesInfo.ExpirationDate = CType(ExpirationDateTextBox.Text, Date)
HeadlinesInfo.ItemID = ItemId
HeadlinesInfo.ModuleID = ModuleId
HeadlinesInfo.Title =
PortalSecurity.InputFilter(Regex.Replace(TitleTextBox.Text, "<[^>]*>",
String.Empty), Security.PortalSecurity.FilterFlag.NoMarkup)
If Common.Utilities.Null.IsNull(ItemId) Then
'Add the new headline.
HeadlinesController.InsertHeadline(HeadlinesInfo)
CompletedTextLabel.Text = "The headline '" + HeadlinesInfo.Title + "' Was
saved to the database."
HasEditFailed = False
Else
'Update the headline
HeadlinesController.UpdateHeadline(HeadlinesInfo)
CompletedTextLabel.Text = "The headline titled '" + HeadlinesInfo.Title + "'
has been updated and saved to the database."
HasEditFailed = False
End If
Catch ex As SqlException
Dim ErrorsList As New StringBuilder
ErrorsList.Append("The headline could not be saved for the following
reasons. Review the list and make sure your entries are correct. When you
are finished reviewing the list, press the OK button to return to the edit
headline form to re-enter your values.")
ErrorsList.Append("<br /><br />")
ErrorsList.Append("<ul>")
For Each ActualError As SqlError In ex.Errors
ErrorsList.Append("<li>" + ActualError.Message + "</li>")
Next
ErrorsList.Append("</ul>")
CompletedTextLabel.Text = ErrorsList.ToString()
EditHeadlineWizard.ActiveStepIndex = 2
'The line below is skipped all the time.
HasEditFailed = True
End Try
End Sub
Protected Sub OKButton_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles OKButton.Click
If HasEditFailed = False Then
Response.Redirect(NavigateURL(), True)
Else
EditHeadlineWizard.ActiveStepIndex = 0
End If
End Sub