Search code examples
asp.netjavascriptfindcontrol

Parent.FindControl() not working?


I have a page that has an iframe

From one of the pages within the iframe I want to look back and make a panel on the default page invisible because it is overshadowing a popup

I tried using Parent.FindControl but it does not seem to be working. I am positive I have the right id in the findcontrol because I used Firebug to inspect the panel and I copied the id from there

Does anyone know what I am missing?


Solution

  • I didn't completely follow your problem, but I'll take my best shot.

    It sounds like you have an ASP.NET page, that has an iframe in it that refers to another ASP.NET page, and in that page that was requested by the iframe you want to modify the visibility of the item contained in the page that contains the iframe.

    If my understanding of your problem is correct, then you have some somewhat nasty problems here.

    1. What's actually happening at the browser level is the first page gets loaded, and that page has an iframe in it that is making a second request to the server.
    2. This second request can't FindControl your control, because it isn't in the same page, and isn't alive during that request.

    So you have some alternatives here:

    1. Get rid of the iframe and use a panel. This will put them both in the same request, and able to find each other.
    2. (Additionally) When you do this you are going to want to use Page.FindControl() not Parent.FindControl() as the FindControl method just searches through the Control's child control collection, and I presume your control will be somewhere else on the page.
    3. On the client side in the iframe you could use some javascript code to access the outer page's DOM, and set the visibility of it there.