Solved

Refresh Parent Page after closing Modal Dialog.

Posted on 2007-03-28
3
3,028 Views
Last Modified: 2007-12-19
Can you make the parent page refresh after you close a modal dialog page? The Modal page is being opened from a click from an Obout treeview.

sHtml = "<span onclick=window.showModalDialog('report.aspx?txtsearch=" & sCaseNum & "',null,'satus:no;dialogWidth:740px;dialogHeight:600;dialogHide:true;help:no;scroll:no')><table cellspacing='0' cellpadding='0' border='0'><tr><td style='width: 75px' >" & sCaseNum & "</td><td style='width: 75px' >" & rTime & "</td><td style='width: 190px' >" & notes & "</td><td style='width: 100px'></td><td style='width: 75px' ><img src='" & HasIncompletedRecordsXImage & "'</tr></table></span>"

The modal page uses this value to retrieve and display a record from the access database. The modal page gets new information from the user and updates the database and then closes.

 I need the treeview to update it's content after this happens. At this point I have to close and restart the page to see the updated data. This is a client request. I am aware that it is much better to just open another page rather than a modal dialog.

Also, if you can't tell. I am fresh out of college and not very experienced  =)

John
0
Comment
Question by:just_joe_
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 5

Accepted Solution

by:
zeroxp earned 500 total points
ID: 18812822
you can do a post back from javascript by using: __doPostBack('target', 'argument');
this will work only when you have the following script on the page, and this script will be generated when you have linkbutton, dropdownlist(auto postback) or similar controls that using a client postback on the form:
<script type="text/javascript">
<!--
var theForm = document.forms['FormID'];
if (!theForm) {
    theForm = document.Form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
// -->
</script>
the target and argument you passed by the __doPostBack() can be accessed by server side use Request.Form["__EVENTTARGET"], Request.Form["__EVENTARGUMENT"]
you can use the retureValue property of the modal dialog to get more control over the post back. the return value can be set in the openned page before closed.
for instance:
//In your openned page(dialog page)
<script type="text/javascript">window.returnValue = 'Need Post Back';window.close();</script>

//In your main page
<script type="text/javascript">
function childDialog()
{
   var returnV = window.showModalDialog('report.aspx?txtsearch=" & sCaseNum & "',null,'satus:no;dialogWidth:740px;dialogHeight:600;dialogHide:true;help:no;scroll:no');
   if(returnV == 'Need Post Back')
   {
      __doPostBack('target', 'argument');
   }
   else
   {
      //do something else
   }
}
</script>

BUT, generally i think we shoul avoid using showModalDialog() where possible, because it does not work in browsers other than IE. use a layer in the same form will be an alternative, or you may simply redirect to anther form and redirect back after process.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question