IFrame page reference

Last post 12-07-2007 2:04 AM by jyoths.cupid. 8 replies.

Sort Posts:

  • IFrame page reference

    03-21-2007, 10:28 AM
    • Loading...
    • sanpran
    • Joined on 12-13-2006, 2:50 PM
    • Posts 23

    Hi,

    Is is possible to get a reference to the controls, public functions, subs etc. of a page that is  INSIDE an IFRAME

    from the outer parent page?

    I have an ParentPage.aspx with an Iframe in it. I set a child page ChildPage.aspx to the Iframe programatically using

    Attributes("Src")  from the ParentPage.aspx.  Now, how can access the controls in ChildPage.aspx from ParentPage.aspx?

    Ex.: ChildPage.aspx (inside the IFRAME) has a formview.  I need to access the formview from ParentPage.aspx and force the data update to SQL through that formview.  Is there a way to do it?

    Thank you in advance.

    Best Regards,

    Praneetha

     

  • Re: IFrame page reference

    03-21-2007, 2:42 PM
    • Loading...
    • bpag
    • Joined on 04-07-2006, 4:05 PM
    • Columbus, OH
    • Posts 533

    I assume that on the server side you want to be able to access a control in the child page from the page that has the iframe in it. You can't do that. The pages are processes as 2 seperate requests. The parent page is loaded and sent to the browser and the browser than handles requesting the child page that is specified in the iframe and displaying it when the page is returned. So when the parent page is being processes the child page is not. I don't understand exactly what you want to have happen though. If you want some action on the parent page to trigger something on the child page there are some ways you could do that. You could access the iframe from from javascript on the client side when something happens in the parent and either reload the iframe passing in a query string to tell it what to do or you could postback the page in iframe and do something. If you want to post back the parent page and then based on whatever happens do something in the child page you could during the postback of the parent page store off some data in session about what you want to do and then when the child page is loaded use that data from session to perform whatever action you want in the child page.

     If none of that help you may want to provide more information about exactly what you are trying to accomplish and the interaction with the user to make what you want to happen happen.

    If this post answered your question please remember to 'Mark as Answer'!
  • Re: IFrame page reference

    03-21-2007, 5:12 PM
    • Loading...
    • sanpran
    • Joined on 12-13-2006, 2:50 PM
    • Posts 23

    Thank you for your help.

    I am trying implement this - "A screen similar to  the .net wizard control interface" ( i.e. the links on the left and the content on the right)

    I want to avoid using the Master page. Instead, I want to use a parent page with links on the left and the iframe on the right for the content.

    The links will open the child pages in the iframe. The child pages will have the formview and the gridview controls connected to SQL. When a user clicks from one link to another on the parent page, it should 

                                                                                         -  save the unsaved data in the current child page to SQL first,

                                                                                         -  then open the new child page in the iframe.

    I can do this only if we can get a reference to the child page in the iframe from the parent page.

    Is there a way to do this?

    Thanks,

    Regards,
    Praneetha

     

     

     

     

    Filed under:
  • Re: IFrame page reference

    03-22-2007, 11:10 AM
    • Loading...
    • bpag
    • Joined on 04-07-2006, 4:05 PM
    • Columbus, OH
    • Posts 533

    There are undoubtedly ways to solve this. I have to tell you that this is a much easier problem to solve using a masterpage. Your masterpage has the links on the left and a content area on the right and then each content page displays the info in the content area just like you do now in the frame and when the use clicks a link it posts back the page that is currently displayed. The page saves its data and then redirects to the page that was selected via the link. Pretty easy thing to accomplish with master pages. With iframes you are working with 2 different pages which means when you click that link in the parent page you are probably going to have to handle it by running some javascript to cause the page in the iframe to post back so it can save its data and then either passing to the posted back page (via a hidden field or something) the url of the next page to go to and have the posted back page redirect to that page when it is done processing or wait until the posted back page comes back to the browser and then have some javascript at that point that handles changing the src of the iframe to go to the next page. The first option is probably easier to implement and may look better from the user's perspective.

    Is there a reason you want to avoid using a master page because this really is a good situation for using master pages.

    If this post answered your question please remember to 'Mark as Answer'!
  • Re: IFrame page reference

    03-22-2007, 12:56 PM
    • Loading...
    • sanpran
    • Joined on 12-13-2006, 2:50 PM
    • Posts 23

    Thanks again for your response.

    The screen I am trying to implement is an employee expense form which is large.  I want to split it into several sections just like the wizard control. 

    I put the sections in different child pages. The parent page gets the snapshot of the expense form ( ex.  form submitter, form status:new, submitted, approved, rejected etc., the approver of the form etc.) . Based on this snapshot, the action menu/buttons and the links are set on the parent. Using the same snapshot,  the parent page tells the child pages to be in the edit/insert/view modes through the querystring.

     If I use master/content pages, the snapshot data will be retrieved eveytime an expense form section is requested. I am trying to avoid the extra SQL call to the database. I want to retrieve the snapshot only once and use it for all the child pages.

    Thanks,

    Best regards,

    Praneetha

  • Re: IFrame page reference

    03-22-2007, 1:16 PM
    Answer
    • Loading...
    • bpag
    • Joined on 04-07-2006, 4:05 PM
    • Columbus, OH
    • Posts 533

    I see. You can still do the same thing with a master page you would just have to do something like strore the snapshot into storage after you load it from SQL and then each subsequent time one of the pages loads you would want to use the snapshot from Session instead of loading it from SQL. You could also make it all one page and use placeholders on your page for the various parts that the links correspond to. Then when the user clicks a link you just hide all the sections that shouldn't show and show the section that should and all of the links and content and all the postbacks and everything all happen within the context of a single page so you can very easily do whatever you need to. Because it is all one form just split into a wizard type UI if I as starting from scratch I would make it all one page and use placeholders to seperate the content into sections to show and hide.

    I'm not saying you have to use master pages or you should rewrite the whole thing if you already have it almost done using iframes. You can certainly do it with iframes as you are doing and get it to work. what you can't do is directly access the childpage in the iframe from the parent page on the server side because they are handled as 2 seperate requests to the server for 2 seperate aspx pages.

    Hope this helps!

    If this post answered your question please remember to 'Mark as Answer'!
  • Re: IFrame page reference

    03-22-2007, 1:20 PM
    Answer
    • Loading...
    • bpag
    • Joined on 04-07-2006, 4:05 PM
    • Columbus, OH
    • Posts 533
    Sorry, don't mean to double post here but I couldn't find a way to edit my previous post. I just wanted to clarify that in that second sentence I meant that you have to do something like store the snapshot into session after you load it from SQL. Didn't mean to say "store it into storage." You would want to put it Session probably so it sticks around across pages.
    If this post answered your question please remember to 'Mark as Answer'!
  • Re: IFrame page reference

    03-22-2007, 9:49 PM
    • Loading...
    • sanpran
    • Joined on 12-13-2006, 2:50 PM
    • Posts 23

    Thank you so much for your help. I will try to use the Master page as you have suggested. I am not well versed in Javascript to try the client side postback.

     Best Regards,

    Praneetha
     

  • Re: IFrame page reference

    12-07-2007, 2:04 AM

    Hi,

    Iam facing the same problem, after entering the data in the child page's textfields If I try to navigate from that childpage.aspx to another childpage it should prompt me that "you have some unsaved data on the page" I cannot switch to masterpage concept. so please help me

    Thanks,

    Jyothi

Page 1 of 1 (9 items)
Microsoft Communities
Page view counter