Solved

Refresh Parent Page after closing Modal Dialog.

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

749 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