accessing usercontrol from another usercontrol

Discussion in 'ASP .Net' started by Phl, Nov 18, 2004.

  1. Phl

    Phl Guest

    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
    Phl, Nov 18, 2004
    #1
    1. Advertising

  2. Phl

    Karl Seguin Guest

    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" <> wrote in message
    news:...
    > 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
    Karl Seguin, Nov 18, 2004
    #2
    1. Advertising

  3. 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
    >
    =?Utf-8?B?VGFtcGEgLk5FVCBLb2Rlcg==?=, Nov 18, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nail
    Replies:
    0
    Views:
    1,539
  2. Fabiano
    Replies:
    2
    Views:
    597
    =?Utf-8?B?c3Jpbmk=?=
    Jun 3, 2005
  3. SlimFlem
    Replies:
    1
    Views:
    371
    Peter Rilling
    Dec 2, 2005
  4. Replies:
    3
    Views:
    3,710
    Arthur
    Jun 23, 2008
  5. protic
    Replies:
    0
    Views:
    352
    protic
    Oct 15, 2008
Loading...

Share This Page