473,396 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

accessing usercontrol from another usercontrol

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
Nov 18 '05 #1
2 1228
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

"Phl" wrote:
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

Nov 18 '05 #2
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

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Phl" <ki************@hotmail.com> wrote in message
news:55**************************@posting.google.c om...
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

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: balu | last post by:
i created a user control for contact information. this control has contact name country etc and also phone number. all these are text boxes. My problem is for phone number i should give 3 text...
2
by: John | last post by:
Hi all, I need to access properties (as well as a couple of methods) from one web page embedded within a usercontrol (with an iFrame inside it) to another usercontrol embedded on the main page...
4
by: Mat | last post by:
Hi, I am having a bit of a problem trying to access / set properties of a usercontrol from the parent codebehind. This is what I have so far.. simple.aspx <%@ Page...
2
by: Fernando Lopes | last post by:
Hi. How can I access a method in the code behind of a user control from the code behind of a page or in the code behind of another usercontrol. I change the method to public and now I access from...
1
by: Chowny | last post by:
I am fairly new to ASP .NET, and am busy teaching myself as I work through my current project. I'm a bit stumped at the moment. I have made a usercontrol called "RelatedClaims" . The code as...
12
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control...
5
by: Alex Maghen | last post by:
Hi. If I create a WebControl (User Control, actually), I know how, easily, to access the design-time Properties that have been set as Propertiy nodes in the tag used on the ASPX page. But I've...
9
by: J055 | last post by:
Hi I have a standard asp page which uses a MasterPage. The MasterPage contains a User control. How can I access a public method in the User control from my WebForm page? I can't move the method...
2
by: acadam | last post by:
In my application I have a usercontrol called "base" with a panel called "pnl1"; in "pnl1" I put my usercontrol. Now I would like to have 2 possibilities: from "base" to load another control...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.