Refreshing parent page from a child page opened as a modal dialog box

B

Bali

Default.aspx is the starting page containing a control(ascx) which has
asp:button control on it. On the button click event it has to open a
new page as a modal control. Since refreshing a page in a dialog box
ended up opening up a new browser window with the aspx page, I read on
a forum that I should use the iframe control and since I have to open
a bunch of pages as diaogboxes, I created a general
page(Container.aspx) which has an iframe control on it, which I then
pass a parameter(pageToGoTo) specifying the aspx page that has to be
opened as a dialogbox.

Sequence of events and code are as follows:

On the default.aspx page I have added a control with a button. On the
button click server side event on that control, I call an aspx page.

string script = String.Format("window.showModalDialog(\"{0}?
pageToGoTo=testWebForm01.aspx\", \"testWebForm01.aspx
\" ,'dialogWidth=520px;dialogHeight=650px;dialogTop=125px;dialogLeft=125px;');",
ResolveUrl("~/Container.aspx"));
Page.ClientScript.RegisterStartupScript(GetType(), "test",
script, true);

On the Container.aspx I have an iframe control called frameTest which
I load on Page_Load event as follows

string pageToGoTo = Request.QueryString["pageToGoTo"];
frameTest.Attributes["src"] = pageToGoTo;

This is then able to load the testWebForm01.aspx in the iframe
control.

Now on a button click event on testWebForm01.aspx I want to close the
testWebForm01 form and reload default.aspx so that the control on
default.aspx. I added the following javascript code to
testWebForm01.aspx

function refreshParent()
{
window.opener.location.href = window.opener.location.href;

if (window.opener.progressWindow)
{
window.opener.progressWindow.close()
}
window.close();

// parent.refresh();
// self.close();
}

and called it on the server side button_click event as follows

string script = "refreshParent()";
Page.ClientScript.RegisterStartupScript(GetType(), "test",
script, true);

I keep getting window.opener is null error.

I read on another forum that if we have used showModalDialog method
then window.opener method is not initialized.

I did play around with trying to initialize it but haven't had any
success.

Does anybody have any idea on how refreshing the parent page can be
accomplished? Please let me know.

Thanks

Sumeet
 
D

Dr J R Stockton

In comp.lang.javascript message <42cf6e15-d24d-4fde-8831-051355c9b990@o4
g2000pra.googlegroups.com>, Sat, 1 Nov 2008 11:33:23, David Mark
Please do not post server side code here.

Ignore that. We already have one control freak; we don't want another.

When one has a JavaScript problem, and the JavaScript is closely
associated with other code running on the same or another machine, then
it may well be necessary to see that other code, and perhaps to suggest
or discuss how it needs to be changed. And one might have code running
server-side that one wants to transfer to client-side JavaScript.
 
T

Thomas 'PointedEars' Lahn

David said:
Please do not post server side code here.

That request needs to be restricted to server-side *non-ECMAScript* code and
to code that is seemingly *irrelevant* to the problem at hand; if it turns
out to be relevant later, it can be posted then. The request might also
further need to be restricted to *uncommented* server-side code.


PointedEars
 
T

Thomas 'PointedEars' Lahn

Dr said:
When one has a JavaScript problem, and the JavaScript is closely
associated with other code running on the same or another machine, then
it may well be necessary to see that other code, and perhaps to suggest
or discuss how it needs to be changed. And one might have code running
server-side that one wants to transfer to client-side JavaScript.

I second that, however it looks like it is more efficient to post the
server-side code only if absolutely necessary to solve the problem, so not
in the first step. Usually one has a problem with client-side code that may
be generated by server-side code; it would be prudent to identify the
problem with the generated client-side code before identifying the possible,
but not necessary, problem with the generating server-side one.

As for "control freak" it's rather a case of the pot calling the kettle black.


PointedEars
 
D

David Mark

In comp.lang.javascript message <42cf6e15-d24d-4fde-8831-051355c9b990@o4
g2000pra.googlegroups.com>, Sat, 1 Nov 2008 11:33:23, David Mark



Ignore that.  We already have one control freak; we don't want another.

Have you lost it? You are supposed to post the *output* of the server
side script (presuming it is not JS.) That isn't my rule (though I do
think it makes sense.)
 
D

Dr J R Stockton

In comp.lang.javascript message <ad818071-e597-4614-81c5-2462ab144e99@r1
5g2000prh.googlegroups.com>, Sun, 2 Nov 2008 18:52:55, David Mark
Have you lost it? You are supposed to post the *output* of the server
side script (presuming it is not JS.) That isn't my rule (though I do
think it makes sense.)

It is the input of the server side script which the programmer needs to
get right. Seeing the output only helps. Trying to solve a half-known
problem is folly. Please grow up.
 
D

David Mark

In comp.lang.javascript message <ad818071-e597-4614-81c5-2462ab144e99@r1
5g2000prh.googlegroups.com>, Sun, 2 Nov 2008 18:52:55, David Mark
<[email protected]> posted:





It is the input of the server side script which the programmer needs to
get right.  Seeing the output only helps.  Trying to solve a half-known
problem is folly.  Please grow up.

As I said, it is not my rule. I thought for sure it was in the FAQ.
Perhaps it should be. It makes sense as it is pretty difficult to
spot problems in client side script when it is intermingled with
server side directives.
 
D

Dr J R Stockton

In comp.lang.javascript message <1ed9d815-47d6-4835-a8c7-e1c7e6e7261c@o4
g2000pra.googlegroups.com>, Mon, 3 Nov 2008 16:05:02, David Mark
As I said, it is not my rule. I thought for sure it was in the FAQ.
Perhaps it should be. It makes sense as it is pretty difficult to
spot problems in client side script when it is intermingled with
server side directives.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,809
Latest member
moe77

Latest Threads

Top