Solved

Refresh Parent Page after closing Modal Dialog.

Posted on 2007-03-28
3
3,008 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_
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now