Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1504
  • Last Modified:

window.showModalDialog does not refresh

Hi,

I am developing a front end for an SQL Server database using ASP. The interface is menu driven. My problem is that I use window.showModalDialog to display the results of a query. However, AFTER viewing the results, if I add more records to the database using the ASP front-end, and query again, I don't see that record being added.

However that record is being added to the database. If I quit the browser and reload the page, the results are shown correctly. If I add any records, before doing a query, those records are shown.

I am certain that this is a problem of window.showModalDialog acting up! Any ideas on how I can force refresh of the modal dialog everytime it loads?

Many Thanx!
Yusuf
0
yusufkhatri
Asked:
yusufkhatri
1 Solution
 
johnczimmCommented:
You need to put your page in a hostframe.
Create a new page called dialogboxhostframe.htm and put the following code after the </head> section:
     <SCRIPT language="JavaScript" type="text/javascript">
          <!--
               window.onerror = handleError;
               
               function handleError() {
                    return true;
               }

               linkURL = ""
               if (location.search) {
                    callingURL = location.search
                    if (callingURL.indexOf('?') != -1) {
                         linkURL = callingURL.substring(callingURL.indexOf('?')+1, callingURL.length)
                    }
               }
         
               document.writeln('<FRAMESET ROWS="0,*" frameSpacing="0" frameBorder="0">')
               document.writeln('<FRAME SRC="" noResize scrolling="no">')
               document.writeln('<FRAME SRC="' + linkURL + '" NAME="ReportData" scrolling="no">')
               document.writeln('<\/FRAMESET>')
               
          -->
     </SCRIPT>

From the page you want to show your modalDialog create a function like this:
function ShowModalDialog(name,height,width) {
     var retval="";
     var props = "dialogHeight: " + height + "px; dialogWidth: " + width + "px; edge: Raised;"
     props += "center: Yes; help: No; resizable: No; status: No; scroll: No;"
     retval=window.showModalDialog('dialogboxhostframe.htm?' + name,window,props);
     if(retval!="" && retval!=null) {
          window.location.replace(window.location.href);
     }
}

To call it use:
ShowModalDialog('TestPage.htm',155,370);
0
 
yusufkhatriAuthor Commented:
Hi johnczimm,

Thanx a lot for your answer. I used a variation of ur suggestion and it worked. Instead of using frames, I used iframe instead, since my target browser shall always be IE.

However, I still dont understand why that happens? Do you have an explanation for that as well?

Many Thanx!
yusufkhatri
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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now