Here is my solution.
I had to drill into the second control returned from the iteration suggested
by Brock.
There were 3 controls in Brock's interation, the second being the form.
Interating over the controls in the form control found the command buttons I
wanted:
=========
Public Class pageHelper
Sub MakeCommandControlsVisible(ByVal user As String, ByVal p As Page)
Dim c As Control
Dim cd As New System.Web.UI.WebControls.Button
Dim fm As New System.Web.UI.HtmlControls.HtmlForm
For Each c In p.Controls
' I found at this level that 3 controls were in the collection.
' The second control was the form on the page
' So drill into this to get teh form controls
If Object.ReferenceEquals(c.GetType, fm.GetType) Then
Dim cntrl As Control
For Each cntrl In c.Controls
If Object.ReferenceEquals(cntrl.GetType, cd.GetType) Then
' If the form control is a command button then copy
it to
' a command button variable
Dim commd As System.Web.UI.WebControls.Button
commd = cntrl
' Depending upon which user set correct combination
of visble buttons
Select Case user
Case "Anon"
Select Case commd.Text
Case "Login"
commd.Enabled = True
Case "Browse"
commd.Enabled = True
Case "new Blog"
commd.Enabled = False
Case "Select"
commd.Enabled = True
Case "View Images"
commd.Enabled = False
End Select
Case "User"
Select Case commd.Text
Case "Login"
commd.Enabled = False
Case "Browse"
commd.Enabled = True
Case "new log"
commd.Enabled = False
Case "Select"
commd.Enabled = True
Case "View Images"
commd.Enabled = True
End Select
Case "Author"
Select Case commd.Text
Case "Login"
commd.Enabled = False
Case "Browse"
commd.Enabled = True
Case "new Blog"
commd.Enabled = True
Case "Select"
commd.Enabled = True
Case "View mages"
commd.Enabled = True
End Select
Case Else
End Select
End If
Next
End If
Next
End Sub
End Class