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

Discussion in 'Javascript' started by Bali, Oct 31, 2008.

  1. Bali

    Bali Guest

    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
    Bali, Oct 31, 2008
    #1
    1. Advertising

  2. Bali

    David Mark Guest

    Re: Refreshing parent page from a child page opened as a modal dialogbox

    On Oct 31, 5:20 pm, Bali <> wrote:
    > 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/window.showModalDialog
    David Mark, Nov 1, 2008
    #2
    1. Advertising

  3. Re: Refreshing parent page from a child page opened as a modal dialog box

    In comp.lang.javascript message <42cf6e15-d24d-4fde-8831-051355c9b990@o4
    g2000pra.googlegroups.com>, Sat, 1 Nov 2008 11:33:23, David Mark
    <> posted:
    >On Oct 31, 5:20 pm, Bali <> wrote:
    >> 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.
    Dr J R Stockton, Nov 2, 2008
    #3
  4. Re: Refreshing parent page from a child page opened as a modal dialogbox

    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
    Laurent vilday, Nov 2, 2008
    #4
  5. Re: Refreshing parent page from a child page opened as a modal dialogbox

    David Mark wrote:
    > On Oct 31, 5:20 pm, Bali <> wrote:
    >> 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
    Thomas 'PointedEars' Lahn, Nov 2, 2008
    #5
  6. Re: Refreshing parent page from a child page opened as a modal dialogbox

    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>
    Thomas 'PointedEars' Lahn, Nov 2, 2008
    #6
  7. Bali

    David Mark Guest

    Re: Refreshing parent page from a child page opened as a modal dialogbox

    On Nov 2, 11:18 am, Dr J R Stockton <> wrote:
    > In comp.lang.javascript message <42cf6e15-d24d-4fde-8831-051355c9b990@o4
    > g2000pra.googlegroups.com>, Sat, 1 Nov 2008 11:33:23, David Mark
    > <> posted:
    >
    > >On Oct 31, 5:20 pm, Bali <> wrote:
    > >> 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.)
    David Mark, Nov 3, 2008
    #7
  8. Re: Refreshing parent page from a child page opened as a modal dialog box

    In comp.lang.javascript message <ad818071-e597-4614-81c5-2462ab144e99@r1
    5g2000prh.googlegroups.com>, Sun, 2 Nov 2008 18:52:55, David Mark
    <> posted:
    >On Nov 2, 11:18 am, Dr J R Stockton <> wrote:
    >> In comp.lang.javascript message <42cf6e15-d24d-4fde-8831-051355c9b990@o4
    >> g2000pra.googlegroups.com>, Sat, 1 Nov 2008 11:33:23, David Mark
    >> <> posted:
    >>
    >> >On Oct 31, 5:20 pm, Bali <> wrote:
    >> >> 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)
    Dr J R Stockton, Nov 3, 2008
    #8
  9. Bali

    David Mark Guest

    Re: Refreshing parent page from a child page opened as a modal dialogbox

    On Nov 3, 3:47 pm, Dr J R Stockton <> wrote:
    > In comp.lang.javascript message <ad818071-e597-4614-81c5-2462ab144e99@r1
    > 5g2000prh.googlegroups.com>, Sun, 2 Nov 2008 18:52:55, David Mark
    > <> posted:
    >
    >
    >
    > >On Nov 2, 11:18 am, Dr J R Stockton <> wrote:
    > >> In comp.lang.javascript message <42cf6e15-d24d-4fde-8831-051355c9b990@o4
    > >> g2000pra.googlegroups.com>, Sat, 1 Nov 2008 11:33:23, David Mark
    > >> <> posted:

    >
    > >> >On Oct 31, 5:20 pm, Bali <> wrote:
    > >> >> 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.
    David Mark, Nov 4, 2008
    #9
  10. Re: Refreshing parent page from a child page opened as a modal dialog box

    In comp.lang.javascript message <1ed9d815-47d6-4835-a8c7-e1c7e6e7261c@o4
    g2000pra.googlegroups.com>, Mon, 3 Nov 2008 16:05:02, David Mark
    <> posted:
    >
    >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.htm> jscr maths, dates, sources.
    <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
    Dr J R Stockton, Nov 4, 2008
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lisa
    Replies:
    1
    Views:
    493
    Matt Berther
    Jan 18, 2005
  2. Samy
    Replies:
    2
    Views:
    1,352
  3. Bali
    Replies:
    0
    Views:
    434
  4. Bali
    Replies:
    1
    Views:
    3,489
    bruce barker
    Nov 1, 2008
  5. gopal srinivasan
    Replies:
    0
    Views:
    231
    gopal srinivasan
    Nov 5, 2004
Loading...

Share This Page