Event Handling and IFrames

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In a "parent" web page I use a literal control to contain IFrame text. The web page displayed in the IFrame has an asp:button control (runat=server)

How do I trap and handle the button_click event of the "child's" button in the "parent" web page. Must I use a delegate

Thank you

John Hopper
 
You can't. The page objects don't exist after the HTML is sent to the
client. Moreover, the server side parent page object is completely unrelated
to the child in the iframe, as that is its own page object.

The best you can do, is have the child window, call a function in the parent
window, that would trigger a postback. Possibly like submitting via a hidden
button. Then on the server, if you handled the click event of that button,
you could do what it is you needed to do.

jbh said:
In a "parent" web page I use a literal control to contain IFrame text. The
web page displayed in the IFrame has an asp:button control (runat=server).
How do I trap and handle the button_click event of the "child's" button in
the "parent" web page. Must I use a delegate?
 
I was describing client side functions, not server side ones.

The child page on the client, can access elements in the parent, and call
methods on them. If one of the methods causes a postback to the parent, then
the parent can act accordingly on the server. But there is no way for the
child and the parent to relate to each other on the server directly, or call
each other's server side methods directly.

jbh said:
Thank you for your response. But I'm missing something. If the child and
parent are unrelated, and can't consume each other's events, then how can I
call a parent page function from a child page?
 
No, that is completely different.

An .ascx is part of the page it is on. It is processed in the same request
since it is just another control on the page (like a textbox or a button),
where as the page in the iframe is processed as a separate request (i.e.
another trip to the server).

I suggest you read up and familiarize yourself with the exact mechanics of
request to the server, and the objects in asp.net that are used to create
the responses.

jbh said:
OK, thank you very much. I guess I'd have the same trouble using .ascx to
generate an event to be handled by its containing .aspx file?
 
Back
Top