?
Solved

Refresh Parent Page after closing Modal Dialog.

Posted on 2007-03-28
3
Medium Priority
?
3,035 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

777 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