View Single Post
  #2 (permalink)  
Old May 1st, 2006, 09:26 AM
Aaron Edwards Aaron Edwards is offline
Friend of Wrox
 
Join Date: Apr 2004
Location: San Francisco, CA, USA.
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Gonzalo,

I've done this myself but with visual basic. The first thing you have to do is reference the control on the content page with the following directive...

<%@Reference Control="~/YourControl.ascx" %>

Then in your codebehind file you can now create an instance of your control and set it equal to the instance on your master page.

Dim ctl As YourControl = Master.FindControl("IDOfInstanceOfYourControlOnMas ter")

This assumes that class name of your control is equal to its file name. If it's not then use the file name in the reference directive, and the class name in the FindControl statement.

Then finally you can do anything you want with myControl, such as ctl.visible=false etc.

That's how you do it in VB. In C# it will be a little bit different.

HTH

Aaron

Reply With Quote