472,121 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,121 software developers and data experts.

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

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=1 25px;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
Oct 31 '08 #1
9 4317
On Oct 31, 5:20*pm, Bali <sumeetkb...@gmail.comwrote:
Default.aspx is the starting page containing a control(ascx) which has
Please do not post server side code here.

As for the modal dialogs, your code shouldn't need to do anything
until the dialog is closed (at which time control returns to it.)
Otherwise, why use a modal dialog?

https://developer.mozilla.org/en/DOM...howModalDialog
Nov 1 '08 #2
In comp.lang.javascript message <42cf6e15-d24d-4fde-8831-051355c9b990@o4
g2000pra.googlegroups.com>, Sat, 1 Nov 2008 11:33:23, David Mark
<dm***********@gmail.composted:
>On Oct 31, 5:20*pm, Bali <sumeetkb...@gmail.comwrote:
>Default.aspx is the starting page containing a control(ascx) which has

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.

--
(c) John Stockton, nr London UK. ??*@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.
Check boilerplate spelling -- error is a public sign of incompetence.
Never fully trust an article from a poster who gives no full real name.
Nov 2 '08 #3
Dr J R Stockton :
David Mark :
>Bali :
>>Default.aspx is the starting page containing a control(ascx) which has
Please do not post server side code here.

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

--
laurent
Nov 2 '08 #4
David Mark wrote:
On Oct 31, 5:20 pm, Bali <sumeetkb...@gmail.comwrote:
>Default.aspx is the starting page containing a control(ascx) which has

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
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Nov 2 '08 #5
Dr J R Stockton wrote:
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
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Nov 2 '08 #6
On Nov 2, 11:18*am, Dr J R Stockton <j...@merlyn.demon.co.ukwrote:
In comp.lang.javascript message <42cf6e15-d24d-4fde-8831-051355c9b990@o4
g2000pra.googlegroups.com>, Sat, 1 Nov 2008 11:33:23, David Mark
<dmark.cins...@gmail.composted:
On Oct 31, 5:20*pm, Bali <sumeetkb...@gmail.comwrote:
Default.aspx is the starting page containing a control(ascx) which has
Please do not post server side code here.

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.)
Nov 3 '08 #7
In comp.lang.javascript message <ad818071-e597-4614-81c5-2462ab144e99@r1
5g2000prh.googlegroups.com>, Sun, 2 Nov 2008 18:52:55, David Mark
<dm***********@gmail.composted:
>On Nov 2, 11:18*am, Dr J R Stockton <j...@merlyn.demon.co.ukwrote:
>In comp.lang.javascript message <42cf6e15-d24d-4fde-8831-051355c9b990@o4
g2000pra.googlegroups.com>, Sat, 1 Nov 2008 11:33:23, David Mark
<dmark.cins...@gmail.composted:
>On Oct 31, 5:20*pm, Bali <sumeetkb...@gmail.comwrote:
Default.aspx is the starting page containing a control(ascx) which has
>Please do not post server side code here.

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.)
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.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "" (SonOfRFC1036)
Nov 3 '08 #8
On Nov 3, 3:47*pm, Dr J R Stockton <j...@merlyn.demon.co.ukwrote:
In comp.lang.javascript message <ad818071-e597-4614-81c5-2462ab144e99@r1
5g2000prh.googlegroups.com>, Sun, 2 Nov 2008 18:52:55, David Mark
<dmark.cins...@gmail.composted:
On Nov 2, 11:18*am, Dr J R Stockton <j...@merlyn.demon.co.ukwrote:
In comp.lang.javascript message <42cf6e15-d24d-4fde-8831-051355c9b990@o4
g2000pra.googlegroups.com>, Sat, 1 Nov 2008 11:33:23, David Mark
<dmark.cins...@gmail.composted:
On Oct 31, 5:20*pm, Bali <sumeetkb...@gmail.comwrote:
Default.aspx is the starting page containing a control(ascx) which has
Please do not post server side code here.
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.)

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.
Nov 4 '08 #9
In comp.lang.javascript message <1ed9d815-47d6-4835-a8c7-e1c7e6e7261c@o4
g2000pra.googlegroups.com>, Mon, 3 Nov 2008 16:05:02, David Mark
<dm***********@gmail.composted:
>
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.

--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk IE7 FF2 Op9 Sf3
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Nov 4 '08 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by luna | last post: by
reply views Thread by leo001 | last post: by

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.