Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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.
================================================== =========
Reply With Quote
  #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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:01 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.