Website User Control Casting Issue

Discussion in 'ASP .Net' started by Tim Payne, May 14, 2008.

  1. Tim Payne

    Tim Payne Guest

    Hi,

    I have a problem with a website project that I've inherited.

    Basically its cr*p. But I need to make some changes to it until we get a
    chance to redo it.

    There is a page that is built dynamically from the database, that contains a
    user control that contains several other user controls and a literal
    control. What I need to be able to do is reference a method in the parent
    control from some of the sub-controls. Obviously that requires me to be able
    to get a strongly typed reference to the parent control, in order to call
    the method.

    And here's where I'm running into problems. In the website model, I can only
    access user controls in a strongly typed fashion if they have added a
    reference to them to the current page control. If I try and add a reference
    to the parent user control to the parent user control, it won't work because
    its a circular reference.

    Does anyone know a way around this? I could just use Parent.FindControl to
    get a reference to the literal in the parent control, but I get the
    impression that I may need to add more complex logic in the near future, so
    I'd like to be able to sort this out.

    Any help or advice greatly appreciated!

    :)

    Cheers,

    Tim.
    Tim Payne, May 14, 2008
    #1
    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. Mad Scientist Jr
    Replies:
    0
    Views:
    626
    Mad Scientist Jr
    Mar 22, 2006
  2. kevin
    Replies:
    11
    Views:
    5,782
    Andrew McDonagh
    Jan 8, 2005
  3. Wally Barnes
    Replies:
    3
    Views:
    510
    Wally Barnes
    Nov 20, 2008
  4. Sosuke

    Up casting and down casting

    Sosuke, Dec 20, 2009, in forum: C++
    Replies:
    2
    Views:
    548
    James Kanze
    Dec 20, 2009
  5. Jonathan Wood

    User Control to Control Other User Control

    Jonathan Wood, Jan 24, 2010, in forum: ASP .Net
    Replies:
    4
    Views:
    530
    Jonathan Wood
    Feb 2, 2010
Loading...

Share This Page