Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

page refresh question/advice 1

Status
Not open for further replies.

LucasH

IS-IT--Management
Oct 28, 2003
93
US
Hi all,

I have developed a web app that takes requests. The initial page lists existing requests. Upon clicking the NEW button, I have a javascript that opens a new window with a blank form. When the user clicks SAVE on the form, the db is updated and another javascript closes the window, returning to the main page.

However since I am only opening a new window and then closing it, the main page is not refreshed, and the new request is not seen by the user who created it. I implemented a little refresh button that they can click to refresh the db pull, but I am hoping there is another way.

Any recommendations? I am getting better with creating/programming these web-apps, but am not all the way there yet. Is there an method that can fire when a page regains focus or something? Can the form call a procedure on the original page?
 
You can try this in the page_load of the pop-up window:
Code:
btn_Save.Attributes.Add("onclick", "javascript:window.opener.document.forms[0].submit();self.close();")

Just change "btn_Save" to what ever the name of your button is called.

Jim

 
dvannoy,

Thanks for the tip, I followed that thread and got it working, not too hard. I created an htm page in my app with the following code;

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>RedirectChildWindow</title>
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content=" <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="ProgId" content="VisualStudio.HTML">
<meta name="Originator" content="Microsoft Visual Studio .NET 7.1">
<script language="JavaScript">
<!--
function refreshParent() {
window.opener.location.href = window.opener.location.href;
if (window.opener.progressWindow)
window.opener.progressWindow.close();
window.close();
}
//-->
</script>
</head>
<body onload="refreshParent()">
</body>
</html>

Then, in my SAVE button CLICK method, instead of closing the window when it's done updating/inserting, I just redirected to the htm page

Response.Redirect("
works like a charm.


If you have a second and understand the java code, can you explain the refreshparent() it to me?


why does he set window.opener.location.href = window.opener.location.href? Isn't that redundant?

What is if (window.opener.progressWindow) checking for? That it exists?

Anyway, I am happy, this works great.
 
jbenson,

I tried you solution, too. It closed the window but didn't refresh the main page for me. It did update the db though.
 
I'm not really sure I can answer that but,,, I think it has something to do with not referencing an object in the parent window.

sorry, I'm not a java guy.

glad you got it working

 
These are good questions, I would like to know myself. Let us know if you get the answers.
 
sorry ..this part is what I was refering to
window.opener.location.href = window.opener.location.href

as far as window.opener.progressWindow

???? who knows

 
Looks like I still have some work to do.

This does what I want it to do, but when it refreshes the main page, it clears any filters, sorts, and returns the user to page 1 of the datagrid. I will have to look into this further. darnit.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top