When you use the StepType of Finish a Finish Button is automatically generated and its ID is “FinishButton”, e.g. the WizardStep looks like this:
<asp:WizardStep ID="ConfirmWizardStep" runat="server" Title="Confirm" StepType="Finish">
Due to a business rule you may wish to disable the Finish button and to do this you would think that a FindControl on the WizardStep would work but it doesn’t as the Button is nested below many other tables/templates etc.
The method I used involved a custom recursive FindControl function as follows:
Dim finishButton As Button = CType(FindControlRecursive(WizardControl, "FinishButton"), Button)
Public Shared Function FindControlRecursive(ByVal root As Control, ByVal id As String) As Control
If root.ID = id Then
Return root
End If
Dim c As Control
For Each c In root.Controls
Dim t As Control = FindControlRecursive(c, id)
If Not t Is Nothing Then
Return t
End If
Next
Return Nothing
Function
No comments:
Post a Comment