Looping thru controls - part 2!!

C

Craig G

i have the routine setup as below. the ctlCollection is populated with Page.Controls. but it only ever brings back 3 controls even though there is more than this on the page

the control types it returns are

1 x "System.Web.UI.ResourceBasedLiteralControl"
1 x "System.Web.UI.HtmlControls.HtmlForm"
1 x "System.Web.UI.LiteralControl"

where am i going wrong?

Cheers,
Craig


Private Sub SetBackgroundColour(ByVal ctlCollection As ControlCollection)

Dim ctl As Control

Try

For Each ctl In ctlCollection

If ctl.GetType.ToString = "Textbox" Then

If CType(ctl, TextBox).Enabled = False Then

CType(ctl, TextBox).BackColor = Color.Transparent

Else

CType(ctl, TextBox).BackColor = Color.LightGoldenrodYellow

End If

End If

If ctl.GetType.ToString = "DropDownList" Then

If CType(ctl, DropDownList).Enabled = False Then

CType(ctl, DropDownList).BackColor = Color.Transparent

Else

CType(ctl, DropDownList).BackColor = Color.LightGoldenrodYellow

End If

End If

Next

end sub
 
C

Craig G

i have a SetMode Method which runs on the page load. For an Add, Edit or
ViewMode

within SetMode i call EnableFields, followed by SetBackGroundColour

and yes the parameter being passed in is Page.Controls

Cheers,
Craig
 

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
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top