modify visibility of master page controls from pages user control?

modify visibility of master page controls from pages user control?

Post by RGFiYmxlc » Fri, 28 Jul 2006 10:14:02


I have some hyperlink controls on a master page I need to disable till my
user has made some selections in a user control on a page based on the master
page. How do I reference the Hyperlink controls in the master page? How can I
get the Master Page to re-render itself after I've done this?

Thanks for any suggestions on this.

Dabbler
 
 
 

modify visibility of master page controls from pages user control?

Post by Arthur Den » Sat, 29 Jul 2006 02:35:18

I would put either a public method on the master page to wrap the
hiding/showing logic, or wrap each hyperlink controls with
Public ReadOnly Property MyLink1 As HyperLink
get
return myHyperLink1
end get
End Property

then in the derived page there is a property (Me.MasterPage i think) which
you can cast to the specific type of your master page.

So with in the derived page you could do something like

CType(Me.MasterPage, myMasterPageClass).MyLink1.Visible = (...some boolean
expression...)

If you have a base page class from which all your pages derive, you could
wrap the MasterPage cast in a property on that base class,
(this is only really simply feasible if you only use a single master page in
your application)
something like...

Class BasePageClass
...
Public ReadOnly Property MyMaster As myMasterPageClass
Get
Return DirectCast(Me.MasterPage, myMasterPageClass)
End Get
End Property
...
End Class