Link to home
Start Free TrialLog in
Avatar of Marc Davis
Marc DavisFlag for United States of America

asked on

Page refresh with IFrame but do not impact iFrame

Hi,

I am looking at a few different things. I am using ASP.NET 4.0 and VB.NET code-behind.

The main situation is this.

I have a page with an iFrame.  We'll call that Page 1 and the page in the iFrame as Page 2. The page of the iFrame on Page 2 is a URL location is external and that page cannot change.

Page 1 is polling the database running on reload of the page which invokes the Page_Load on the reload. That Page_Load is executing the stored procedure to check certain values in a table. Page 2 (the one in the iFrame) is where certain information is entered and will have a submit button. After a period of time, information from the Page 2 will go into the same table that I am polling on Page 1.

What is going on is every time Page1 reloads (based on like 10 second interval) the data in Page 2 (in the IFrame) is lost.

How can I keep that from happening?

I can think of one way, off the cuff, and that is to use the Page 1 and Page 2 as a frameset. And one Frame (for the Page 1) is doing the polling and reloading... The other frame is doing the Page 2 but in an iFrame.

When the user hits the "Submit" button on the second frameset (Page 2) then break out of the frameset and only have the Page 1.

Break out of the Frameset from the code behind of Page2 with JavaScript like? Or is there another way?

Page.RegisterClientScriptBlock("ResetPage", "<SCRIPT>top.location.href=" + Page1URL + "</SCRIPT>");

Open in new window


That is one option. Is there another option using AJAX to reload everything on the page 1 EXCEPT for the iFrame (Page2)?

Any thoughts or suggestions would be greatly appreciated.
Avatar of HainKurt
HainKurt
Flag of Canada image

page 1:

...
<div id=mainContent>
  all page content here
</div>
<iFrame for page 2 somehwre outside of main content>

Open in new window


now, on page1, you can say

$("#mainContent").load("page1 #mainContent")

Open in new window


so, ajax will get the page1, but just use #mainContent and update #mainContent / replace it...
ASKER CERTIFIED SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Use Master and Content page. iFrame mainly use for advertisement.
Avatar of Marc Davis

ASKER

Eventually I will be putting this under a Master and Content page.

This iFrame is not for advertisement.
Huseyin, I am reloading that page 1 with:

setTimeout(function () {
            location.reload();
        }, 5000);

Open in new window


And the Page_Load is actually calling the SP to look for the values in the table.

So, there wouldn't necessarily be "content" in the mainContent.

Page 1 is polling and the Iframe is in there. One can arguably say that the content of the mainContent is the iFrame (running the page 2).

That's why I was using the framesets. I moved that iframe from Page 1 and have that running in one frameset and then Page 2 in another frameset then we the conditions were met from the Page 1 polling I broke out of the frameset and went to another page. All was good. BUT then I realized the Master pages needed to be used and a frameset will not work with a Masterpage.
Also Huseyin, the iFrame on Page 1 that is running Page 2 is outside of the DIV tag.

But I am not getting your:

$("#mainContent").load("page1 #mainContent")

Open in new window


Where would that reside and would I need to have the "page1" reference if the maincontent is on that page?
All, disregard. I got it. I used Ajax and a web service method. Its functioning as expected!

Huseyin, I will be taking yours a the best solution and giving you the points.
Issue has been resolved as I implemented a webservice function and javascript for a different timer and not a reload.
I am glad it helped :)