HighTechTalks DotNet Forums  

Access container during OnInit

ASP.net Building Controls microsoft.public.dotnet.framework.aspnet.buildingcontrols


Discuss Access container during OnInit in the ASP.net Building Controls forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Peter Zolja
 
Posts: n/a

Default 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"
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.



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.