473,796 Members | 2,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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)Pa ge.FindControl( "EditProfil e");

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 1243
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)Pa ge.FindControl( "EditProfil e");

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.FindContro l(), 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.goo gle.com...
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)Pa ge.FindControl( "EditProfil e");

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
1461
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 boxes. where textbox1 is for area code,textbox2 is for exch and textbox3 is for last four digits in phone number. My requirement is when user enter 3 numbers in textbox1 the focus should automatically go to textbox2. Problem... Since the above...
2
1348
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 within a placeholder. How do I go about this? Regards John.
4
1886
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 Inherits="CodeBehindSimple" src="simple.vb" %> <%@ Register TagPrefix="CC" TagName="Simple" Src="ucSimple.ascx"%>
2
1180
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 the Page. But, there is any problem using this way? (public method) Anyone knows another way? How can I access from another usercontrol? Thanks.
1
1212
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 follows : '******************************** Private sLinkType As String
12
2212
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 server. It "serves" back the required control (either WebControl or UserControl) based on the contents of an xml file. The code in the webform places each control in a TableCell. My problem is that the control server works as far as returning the...
5
1869
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 never tried having CONTENT inside my Control's Tag, e.g.: <Ax:MyCtl id="Something" runat="server"> Some stuff inside the tag </Ax:MyCtl> How do I access the body from the code of my Control (i.e. above, "Some
9
2651
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 to another location because it populates a Textbox in the user control page. Thanks Andrew
2
1593
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 called "ctl2" (and there's no problem) but I would like also to load "ctl2" from "ctl1"! The name of the control to load is "stored" into Session("activeCtl") base.ascx Page_Load code: Dim ctl As UserControl = New UserControl
0
10459
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10018
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7553
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6795
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5446
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4120
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3735
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.