Website User Control Casting Issue


T

Tim Payne

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.
 
Ad

Advertisements


Top