Access container during OnInit

P

Peter Zolja

Here's my scenario:

In my ASPX file I have something like this:

<cc:MyContainer runat="server" ID="MyContainer1" FunkyClassName="Class1">

<cc:MyControl runat="server" ID="MyControl1"
FunkyObject-SomeProperty="text">

</cc:MyContainer>

What I'm trying to do is have the "FunkyObject" be created dynamically using
reflection based on the container's "FunkyClassName" property value.
Everything works until the ASPX file actually looks like above. In this case
the framework tries to set MyControl1's FunkyObject-SomeProperty to "text"
in the initialize phase (OnInit). The problem is that at this stage the
control tree is not fully built and MyControl1 cannot access the parent
container to find out what kind of type the FunkyObject should be. As far as
I know this is by design, so it's behaving like it should.

My question is: can you think of a way (hack?) around this? I could move the
FunkyClassName="Class1" declaration inside MyControl or store that value in
web.config, however, the best way (for my case) would be if I could store it
as a property of the container...

Any ideas?

Thank you,
Peter.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top