user controls containing other user controls

I have a ContactInfo custom class that exposes AddressInfo custom class as property. I created two User Controls, you guess, Contact.ascx and Address.ascx.  Address.ascx exposes property Address as AddressInfo.  I am running into following problem. In Contact.ascx in page_load sub I am trying to set the values of the Contact class like this :

_contact.PrimaryAddress = ctlAddress.PrimaryAddress

but since value of the PrimaryAddress property in Address.ascx is set also in Page_Load, above code will not work since there is no instance of this object yet. Is my only option to make this work to raise an event from child control to notify Contact.ascx that that Address has changed.

You died at the very end of your life
exptrade2000 10/6/2004 7:36:34 PM
📃 4216 articles.

💬 1 Replies
I would use databinding.

<cc1:Contact id=foo runat=server PrimaryAddress=<%#bar.PrimaryAddress%> />
<cc2:Address id=bar runat=server />
Then after everything has loaded maybe in prerender just call databind on your control.
stevemc 10/6/2004 10:39:27 PM