Access container during OnInit - 01-30-2007 , 05:53 PM
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"
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...
|Thread Tools||Search this Thread|