Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 27th, 2006, 09:48 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default how to reference user control in master page..

hi all..

i have an user control inside a master page.. how can i find it ??

i know i have to do something like:

ctype(master1.findcontrol("back"),???)

where ??? is my problem.. how can i tell what type my control is.. i know it name but i cannot find any way to tell the ctype how to cast it...

thanks in advance...



HTH

Gonzalo
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
  #2 (permalink)  
Old May 1st, 2006, 09:26 AM
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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Master Page - User Control communication Aaron Edwards ASP.NET 2.0 Basics 8 March 7th, 2008 08:52 AM
User Control not rendering in Master Page skmcusp ASP.NET 2.0 Basics 2 September 10th, 2007 04:58 PM
Master Page File Reference bandrsolutions ASP.NET 2.0 Basics 2 February 7th, 2007 12:26 PM
Access Master page control from Content page. angshujit ASP.NET 2.0 Basics 3 January 11th, 2007 06:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.