Greg Smith said:
What is the syntax to reference a control on another page? I have a class
module that I would like to code to change parameters on a series of
controls on a web page. There are to many to pass by reference. Is there
a way to do something like
If this class (one no longer says "class module") is specifically for this
one page (as it must be since it is meant to touch this large set of
controls), then perhaps it should be part of that page.
Do you see yourself reusing this same class for a different page? If so,
then perhaps the set of controls to be manipulated by this class should be
broken out into their own UserControl, and perhaps the logic from your class
should become part of the UserControl. Are these controls physically
contiguous?
If your class knows details about the page, then you can give it access to
the page by passing "Me" to it:
Public Class WebForm1
Inherits System.Web.UI.Page
Friend WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Friend WithEvents TextBox2 As System.Web.UI.WebControls.TextBox
Friend WithEvents TextBox3 As System.Web.UI.WebControls.TextBox
#Region " Web Form Designer Generated Code "
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim c1 As New Class1()
c1.EnableControls(Me)
End Sub
End Class
Public Class Class1
Public Sub EnableControls(ByVal page As WebForm1)
page.TextBox1.Enabled = True
page.TextBox2.Enabled = True
page.TextBox3.Enabled = True
End Sub
End Class
But notice that Class1 can only be used by one page. In this case, there's
no real sense in creating a class for it - it should be part of the page.
John Saunders