Web forms are derived from System.Web.UI.Page. However, you'll find your
foreach statement to be inadequate, as you will only get the root level
controls. If you have any container controls (such as a table) their
children will not be iterated through, so you will need to make this call
recursively if you want to get that absolutely everything.
But, if you need to go through everything each time, this is a rather slow
and tedious approach. You may want to consider deriving some custom server
controls that have the properties you need, which will make your application
perform exponentially better.
--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--
"Tomk" <to****@hotmail.com> wrote in message
news:uS**************@tk2msftngp13.phx.gbl...
I would like to make a routine that I can reuse on all my web forms to loop
thru all webcontrols. However to do this I will need to pass a reference
of
the class that is associated with the form but I can't figure out the type
to use in the method paramenter.
something like this:
Public Class myWebForm
Inherits System.Web.UI.Page
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
InitializeComponent()
Dim objCommonRoutine as new myCommonRoutine()
Call objCommonRoutine .DoStuff("Select * From Table", Me)
End Sub
End Class
Public Class myCommonRoutine
Public Sub New()
End Sub
Public Sub DoStuff(ByVal strStuff as String, ByRef objWebForm as ????)
For Each WebControl in objWebForm
bla bla
Next
End Sub
End Class