Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > accessing usercontrol from another usercontrol

Reply
Thread Tools

accessing usercontrol from another usercontrol

 
 
Phl
Guest
Posts: n/a
 
      11-18-2004
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
 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      11-18-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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



 
Reply With Quote
 
 
 
 
=?Utf-8?B?VGFtcGEgLk5FVCBLb2Rlcg==?=
Guest
Posts: n/a
 
      11-18-2004
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
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing vb of usercontrol within usercontrol protic ASP .Net 0 10-15-2008 11:26 AM
Can you load a usercontrol into another usercontrol? COHENMARVIN@lycos.com ASP .Net 3 06-22-2008 11:00 PM
Having a UserControl returned in a string from another UserControl to be rendered SlimFlem ASP .Net 1 12-02-2005 10:14 PM
Getting a property of a control inside a usercontrol, from another usercontrol Fabiano ASP .Net 2 06-03-2005 09:56 AM
Access a control inside an usercontrol from another control inside another usercontrol nail ASP .Net 0 09-15-2004 03:55 PM



Advertisments