Accessing Controls Within Wizard StepNavigationTemplate

C

charleswesley

I've searched this group and found several posts relating to this all
of which have the following "solution":

TextBox textBox1 =
WizardStep1.CustomNavigationTemplateContainer.FindControl("TextBox1")
as TextBox;

My problem is that when I try to do this I get an error stating that
"CustomNavigationTemplateContainer is not a member of
System.Web.UI.WebControls.WizardStep"

Here is my template:

<StepNavigationTemplate>
<asp:Button runat="server" ID="btnAnswer" Text="Submit Answer"
CssClass="NavigationButton" OnClick="SubmitAnswer" />
<asp:Button runat="server" ID="btnMoveNext" CommandName="MoveNext"
Visible="False" />
<asp:Button runat="Server" ID="btnMovePrevious"
CommandArgument="MovePrevious" Visible="false" />
</StepNavigationTemplate>

All I want to do is change the visible properties on the btnAnswer and
btnMoveNext button controls depending on some conditional logic I have
in the SubmitAnswer sub.

What would the code look like that would access these controls?!
 
C

charleswesley

This is the only way I've been able to find to do this:

***********************
* code behind *
***********************

Sub MySub(ByVal sender As Object, ByVal e As EventArgs)
Dim btnAnswer As Button = Me.FindMyControl(wiz1.TemplateControl,
"btnAnswer")
btnAnswer.Visible = False
End Sub

Function FindMyControl(ByVal ctrlStart As Control, ByVal ctrlEnd As
String)
Dim ctrl As Control

For Each ctrl In ctrlStart.Controls
If ctrl.ID = ctrlEnd Then
Return ctrl
Else
If ctrl.HasControls Then
Dim c As Control = Nothing

c = FindMyControl(ctrl, ctrlEnd)

If Not c Is Nothing Then
Return c
End If
End If
End If
Next

Return Nothing
End Function

***********************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,129
Messages
2,570,770
Members
47,329
Latest member
FidelRauch

Latest Threads

Top