473,715 Members | 5,414 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Refresh Parent from iframe Page_Load

Hi,

I have a page with a very data intensive grid which needs to be
automatically refreshed constantly if a change is detected. In order to
not refresh the complete page so often, I created an iframe on my page
whose html has the refresh meta as follows :

<meta http-equiv="refresh" content="10">

The iframe is effectivelyh refreshed every 10 seconds without having the
grid refreshed. Now, inside the Page_Load of the iframe page I am
determining if the grid needs to be refreshed.

How can I instruct the parent page to refresh itself?

Thanks,

Jeronimo
Nov 18 '05 #1
2 23503
Hi Jeronimo ,
Thank you for using MSDN Newsgroup! My name is Steven, and I'll be
assisting you on this issue.
From your description, your question is how to refresh a parent page from a
sub page which is located in a <iframe> tag in the parent page.
If there is anything I misunderstood, please feel free to let me know.

As for this quesiton, I think we can solve it using the client side
javascript. Generally, when we want to retrieve the parent page's object
handle in a sub page( in <iframe> or <frame> ), we can use the
"window.par ent" object. If
we want to refresh a page, we can use set the
"window.locatio n.href=window.l ocation.href" to load the page's url again.
So combine the twos, we can use the below javascript code to refresh a
parent page:
"window.parent. location.href = window.parent.l ocation.href;"

Also, since you determine whether to refresh the parent page in the sub
page's serverside Page_Load event handler, you need to add the above
javascript block into the page in Page_Load. You can use the
"Page.RegisterS tartupScript" function to register a client script block.
For example:

Page.RegisterSt artupScript("Re freshParent","< script
language='javas cript'>RefreshP arent()</script>");

You can call this when you need to refresh the parent page in the Page_Load
event handler.

In addition, to make the above things clearly, I've made two demo pages,
you may try them out if you like:
------------parent aspx page:-----------------------
<HTML>
<HEAD>
<title>WebForm1 </title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table width="500" align="center">
<tr>
<td>
<asp:Label id="lblMessage " runat="server"> </asp:Label>
</td>
</tr>
<tr>
<td>
<iframe src="SubPage.as px"" width="100%" height="1"></iframe>
</td>
</tr>
</table>
</form>
</body>
</HTML>
------------parent code-behind page class------------------
.............
private void Page_Load(objec t sender, System.EventArg s e)
{
lblMessage.Text = System.DateTime .Now.ToLongTime String();

}
............... ..

-----------------Sub page (in parent page's iframe) aspx page
code----------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>SubPag e</title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
<meta http-equiv="refresh" content="1">
<script language="javas cript">
function RefreshParent()
{
window.parent.l ocation.href = window.parent.l ocation.href;
}
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">

</form>
</body>
</HTML>
-------------------Sub page code-behind class
code---------------------------
public class SubPage : System.Web.UI.P age
{

private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
System.Random rnd = new Random();
int i = rnd.Next();

if(i%2 == 0) //simulate determine whether to refresh parent page
{
Page.RegisterSt artupScript("Re freshParent","< script
language='javas cript'>RefreshP arent()</script>");
}

}

override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}
private void InitializeCompo nent()
{
this.Load += new System.EventHan dler(this.Page_ Load);
}

}
------------------------------------------------------

Please try out the preceding suggestion. If you have any questions on them,
please feel free to let me know.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #2
Hi Steven,

Thanks!!! It worked like a charm.

Jeronimo

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
23504
by: Raj | last post by:
Hi All, I have a problem with trying to refresh the parent window from child window in order to update data in the parent window. The sequence of events are 1) I click a button in the parent window to open a child window thru javascript window.open 2) I have some functionality in the child window that changes the data
2
7384
by: Sheryl Landon | last post by:
Hi, I'm having a similar issue as the poster Mike whose message I copied below... I have a page with an iframe... when I discover that the session state is no longer valid in the page inside the iframe, I want to redirect the parent page to a login page. Can anyone help me? Thanks, Sheryl "MLibby" <mlibby@nospam.nospam> wrote in message
2
3466
by: J-T | last post by:
Hello, I have an iframe which its scr is set to show a url (am image) .I am put this iframe on a user control and I am loading that user control dynamically to my Default.aspx.Now I need to refresh the content of the iframe every 2 minutes .I used a java script code in user conrol ,the referesh happens but the content of the iframe dosen;t get changed,I mean it dosen;t get refresh! How can I do that?
2
17080
by: superfreaker | last post by:
Ok, I've been at this two days now and have scoured the group for help to no avail. I have a main web page that contains a form and an iframe. I need to submit the form and set the iframe source file in one action and have it work with both IE and other browsers. So far, i have not had any luck. Form name "fmUpload", frame name, "progframe".
0
380
by: Chukka | last post by:
I have iframe inside Firstpage.aspx page like this... <IFRAME id="IFrame_One" style="WIDTH: 1029px; HEIGHT: 425px" name="IFrame_Documents" marginWidth="0" marginHeight="0" src="http://int.comp.com/secure/dir/toLoadpage.aspx" frameBorder="0" scrolling="yes"></IFRAME> When I open Firstpage.aspx, the page inside the iframe (toLoadpage.aspx) loads twice (confirmed from logs, it's not just graphical refresh). The frame literally loads the...
2
7133
by: Raffi | last post by:
My main browser page has an iframe. Whenever the iframe is reloaded (updated), I want to automatically refresh the main webpage as well. How can this be done, preferably using javascript? Thanks, Raffi
1
1357
by: govindsharma53 | last post by:
Hi, i read your article on refreshing parent page from iframe on page_load . http://www.thescripts.com/forum/thread299739.html I tried to implement this in my project but it gives me error that Page.RegisterStartupScript is Obselete so i tried with ClientScript.RegisterStartupScript(Me.GetType(), "RefreshParent", "<scriptlanguage='javascript'>RefreshParent()</script>")....But it does not refresh the parent page.Kindly let me know your...
0
9198
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9047
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6646
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5967
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4477
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4738
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2541
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2119
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.