Call a function on another WebForm?

D

Dean Slindee

Would like to call the TabShow function on WebForm InOutHost from another
WebForm in same project, but cannot figure out how to get a reference. Can
this be done? In this statement: Call InOutHost.TabShow("pagBoard"), the
reference to InOutHost is not resolved. Thanks, Dean S


Partial Public Class InOutHost

Inherits System.Web.UI.Page

'function

Public Sub TabShow(ByVal strTabName As String)

Select Case strTabName

Case "pagSearch"

tabInOut.SelectedTab =
tabInOut.Tabs.IndexOf(tabInOut.Tabs.FromKey("pagSearch"))

Case "pagBoard"

tabInOut.SelectedTab =
tabInOut.Tabs.IndexOf(tabInOut.Tabs.FromKey("pagBoard"))

Case Else

'error message

End Select

End Sub

End Class



Partial Class Search

Inherits System.Web.UI.Page

Call InOutHost.TabShow("pagBoard")

End Class
 
K

Karl Seguin [MVP]

Create a base class, or a utility function. You want to access a member of
a something that doesn't exist. If this is truly functionality that both
pages offer, you should place it in a base class, which inherits Page, and
make your 2 pages inherit from it

Karl
 
D

Dean Slindee

Both WebForms exist in the same project. Each has a very distinct/different
task to accomplish, so they have nothing (but residing in the same project)
in common. Can you tell me whether it is possible for two WebForms to
communicate with each other. This can be done with WinForms, easily. Just
want to know if it's possible with WebForms, and how.
Thanks,
Dean S
"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:[email protected]...
 
K

Karl Seguin [MVP]

A WebForm is just a class.

When a page is requested, an instance of the given webform is created.

No instance of the 2nd webform exists, so only static/shared members can be
accessed. In other words you can't access Page2 because it doesn't exist at
that given time.

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


Dean Slindee said:
Both WebForms exist in the same project. Each has a very
distinct/different task to accomplish, so they have nothing (but residing
in the same project) in common. Can you tell me whether it is possible
for two WebForms to communicate with each other. This can be done with
WinForms, easily. Just want to know if it's possible with WebForms, and
how.
Thanks,
Dean S
"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:[email protected]...
 

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

Top