www.webdeveloper.com
Results 1 to 6 of 6

Thread: showModalDialog refresh parent problem

  1. #1
    Join Date
    Sep 2005
    Posts
    10

    Unhappy showModalDialog refresh parent problem

    Hi

    I am using window.showModalDialog to open a modal dialog.
    On click of the submit button on my modal dialog I want
    1. the modal dialog to close.
    2. the parent page to get refreshed.

    The following script closes the dialog but is not able to refresh the parent page (though it does not give any error)

    <script language = "javascript">
    function CLoseRefresh()
    {
    window.parent.location.reload();
    window.close();
    }
    </script>

    I have tried various combinations but none seem to work. (window.opener is not accessible)
    Note: the above mentioned script works fine if I use a window.open instead of window.ShowModalDialog. (I cannot use window.Open bcoz of the nature of the page).

    Is it possible to cause the parent to b refreshed?
    Any help wud be super superAppreciated.

    Thanks

  2. #2
    Join Date
    Feb 2005
    Location
    USA
    Posts
    1,534
    why don't you just have window.location.reload() on the parent page immediately after your window.showModalDialog() function. Are you aware that that function is synchronous and puases the parent parser in the same way alert() does? More importantly, are you aware it only works in IE?

  3. #3
    Join Date
    Sep 2005
    Posts
    10
    Hi BigMoosie,
    Thanks for the reply.

    Quote Originally Posted by BigMoosie
    More importantly, are you aware it only works in IE?
    Yes. I am developing an intranet site for a company. They use IE only.

    Quote Originally Posted by BigMoosie
    Are you aware that that function is synchronous and puases the parent parser in the same way alert() does?
    If you say so. Though this fits in well with the requirements.

    Quote Originally Posted by BigMoosie
    why don't you just have window.location.reload() on the parent page immediately after your window.showModalDialog() function.
    Won't that refresh the page right after the popup is opened. (Correct me if I am wrong. Maybe I am not understanding what's synchromous and what's not).
    I want the parent page to refresh after I press the submit button on the modal dialog (this updates a database). The parent page needs to refresh with the new database values.

    Thanks

  4. #4
    Join Date
    Feb 2005
    Location
    USA
    Posts
    1,534
    Like I said, it is synchronous, basically that means that the code freezes as soon as you open your dialogue, when you close the dialogue it picks up where it left off and will refresh only then.

  5. #5
    Join Date
    Sep 2005
    Posts
    10
    Hi

    Thanks.
    This works for normal html pages but does not work with aspx pages (.NET) because I have to use RegisterClientScript which has a different way of injecting script.

    Anyway, thanks a lot for giving me the idea.
    Super appreciated!!

    Thanks
    supernewbie

  6. #6
    Join Date
    Jun 2009
    Posts
    1

    hi

    just write (window.location = window.location for open modalDialog script code
    Example:

    Page.ClientScript.RegisterStartupScript(this.GetType(), "alert",
    "<script language='javascript'> var modalDial = window.showModalDialog(\"MainModal.aspx?UC=Nationalities\",null, \"dialogWidth:406px; " +
    "dialogHeight:310px; help: No; center:yes; resizable: no; status: no; \"); " +
    "window.location = window.location; </script>");

    its working fine with me. I hope this one help.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles