accessing usercontrol from another usercontrol

P

Phl

Hi,

I have a page with many usercontols and I would like to access other
usercontrols from one usercotnrol , so I can access their server
controls. This is how I do it,

EditProfile UserControlep =
(EditProfile)Page.FindControl("EditProfile");

This works when I debug it in my localmachine but doesn't when I have
my page running on my production server. Does anyone know why is this
because the usercontrols ID can get changed by .net? If so, I can't
see the id of of usercontrol in the rendered page anyway, so how can I
access it?

Cheers
 
K

Karl Seguin

Phl,
check out my article which discusses this type of issue:
http://openmymind.net/communication/index.html

i don't talk about using Page.FindControl(), instead I advocate using a
public property in the page that exposes the user control, far more
performant and less likely to cause this type of error..

Karl
 
G

Guest

You can treat usercontrols just like you would treat a class. You must
declare public methods or properties in code that you want to be exposed to
other classes in the usercontrol. By default everything is hidden
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top