Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

window.showModalDialog

Status
Not open for further replies.

livezone

MIS
Jan 17, 2003
81
CA
Hi, I am using Modal Windows to input data for certain stores. Once data entered it is stored in sql table. When I close the modal window and I open it again it does not return the databack. The problem is that it is not querying it right

function openModalWin(Mode)
{
sku = frmNewRequest.sku.value;
qty = frmNewRequest.qty.value;
store = frmNewRequest.dropStore.value;
if ( sku != "" && qty != "" && !isNaN(qty) && !isNaN(sku) && qty > 0 )
{
window.showModalDialog('Distribution.aspx?Store=' + store + '&Sku=' + sku +'&Qty=' + qty + '&Mode=' + Mode,'null','width=520,height=500,top=10,left=10,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes');
return false;
}
}

Does anyone know any problem with modal dialog window?
 
Don't know of any problems of the type you mention, but I do notice that your options string to the showModalDialog function is incorrect. It should NOT look like the options string for a normal window open. It should look like this:
Code:
"dialogheight:190px;dialogwidth:350px;dialogtop:200px;dialogleft:150px;"
You can also leave out dialogtop and dialogleft and it will center the modal dialog.

Note that you CANNOT specify statusbar, toolbar, menubar, etc. - modal dialogs don't have those anyway. Also, you cannot specify scrollbars - you will get them when needed whether you like it or not (unless, of course, you put "style=overflow:hidden" in the body tag of your dialog page.


Meddle not in the affairs of dragons,
for you are crunchy, and good with mustard.
 
Thanks for the correction. But this is really a strange behaviour, I am getting.

Is there any known problem using window.showModalDialog and refresh page.

I have an image button which will open the dialog box with this script javascript.

<code>
dialogUrl = "Distribution.aspx?Store=" + store + "&Sku=" + sku +"&Qty=" + qty + "&Mode=" + Mode;
dialogOption = "dialogheight:520px;dialogwidth:520px;";
window.showModalDialog(dialogUrl,'null',dialogOption);
</code>

Page uses a datagrid to input some information. Information is saved to data base (working). When closing that dialog and clicking on the button to show the dialog again. But it does not bring the updated information it still shows the old information although database has updated data. It seems it is not querying properly on 2nd opening. But when the whole browser is closed and then open it again. Then it brings the right information.
 
It sounds to me like a refresh/caching problem. Try adding the current time to your URL to help prevent caching, and include one of the anti-caching headers in your modal dialog html file.

Here's how I add the time:
Code:
var theDate = new Date();
var theTime = theDate.getTime();
var sURL = myURL + "?time=" + theTime;

I don't have a place to get a copy of the no-cache header handy, but someone here should be able to supply one.

Meddle not in the affairs of dragons,
for you are crunchy, and good with mustard.
 
You r right buddy. It was caching problem. I spent ton of hours debugging this problem. Thanks

That's what I use in the HTML Header
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
 
I can't tell you how many times I've made changes to some javascript code and wondered why it didn't appear to change anything, only to realize that it was a caching problem. It's even less apparent when the page that is being cached is not being loaded directly into the browser, but called from inside your code. It's very frustrating!

In IE you can force a complete reload of the page and all it's subsidiary files (style-sheets, included javascript files, images, called pages, etc.) by holding down the Ctrl button while you click on Refresh.


Meddle not in the affairs of dragons,
for you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top