views:

20

answers:

2

I have a troubling task. I have a page contained within an outer frame, on the outer frame is a user control which i need to populate with some data from within the containing page. The problem is the outer frame is rendered before i can get hold of the required data. How can i accomplish this?

A: 

Couldn't you just create a public Populate sub in your user control and call it from the outer frame when required data is loaded? Populate would take the data as arguments and populate the control with this data.

Meta-Knight
A: 

I would use a JavaScript to accomplish this. You can put a Populate method in JavaScript in the parent page with whatever signature you want.

function PopulateControls(param1, param2, param3) 
{
    document.getElementById('<%=this.Control1.ClientID%>');.value = param1;
    document.getElementById('<%=this.Control2.ClientID%>');.value = param2;
    document.getElementById('<%=this.Control3.ClientID%>');.value = param3;
}

Then in the child frame, make sure the page has a built in JavaScript to pass it back up.

window.onload=SendToParent;

function SendToParent() 
{
   window.opener.PopulateControls('<%=this.Field1.ClientID%>','<%=this.Field2.ClientID%>',<%=this.Field3.ClientID%>');

}

You might have to tweak the code above, but the gist is that the parent page controls will end up waiting until the child page is fully loaded before it's done. If you want to use labels and whatnot, you can use the InnerHTML property on divs instead.

Joel Etherton