By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,836 Members | 2,016 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,836 IT Pros & Developers. It's quick & easy.

Need to refresh page after calling showModalDialog

P: n/a
I have Search form that allows users to retrieve records into a
DataGrid. There are two search criteria - a Month and a Year, which
are selected from drop-down lists. There is a server-side button
called "cmdFilter" which retrieves data from the database using any
criteria thus selected.

For any of the records retrieved into the grid match certain
conditions, one of the columns will be formed into a hyperlink.
Clicking on this will allow the user to display a modal dialog, at
which point the user can manipulate the data displayed.

The hyperlink is created server-side like so (in the ItemDataBound
event):

Dim drv As DataRowView = CType(item.DataItem, DataRowView)
Dim Rule As String = CType(drv.Item(0), String)
Return "<a style='COLOR:black' href='javascript:ShowUploadInfo(""" &
Rule & """)'>Upload</a>"
When the user closes the pop-up, I'd like the underlying form to be
refreshed.

Here's what I've done.

In the .aspx file for the Search form (the "parent" or "calling" form)
I have the following:

function ShowUploadInfo(uploadDate) {

// Save search variables
//document.all.item("txtHiddenStartDate").value =
document.all.item("txtStartDate").value;
//document.all.item("txtHiddenEndDate").value =
document.all.item("txtEndDate").value;
//document.all.item("txtHiddenMonth").value =
Number(document.getElementById('cboCalendarMonth') .value);
//document.all.item("txtHiddenYear").value =
Number(document.getElementById('cboCalendarYear'). value);

var str =
window.showModalDialog('../Popups/UploadInfo.aspx?uploadDate=' +
uploadDate,'',
'dialogHeight:800px;dialogWidth:805px;status=no,to olbar=no,menubar=no,resizable=no,location=no,scrol lbars=no','','unadorned:yes');

// POINT 1 POINT 1 POINT 1 POINT 1 POINT 1 POINT 1 POINT 1 POINT 1
if (!str)
{
str = "";
}

if (str.length == 0)
{
return;
}
else
{
debugger;
// attempt to execute cmdFilter.Click event in VB code behind
document.all.item("cmdFilter").click();
}
// POINT 2 POINT 2 POINT 2 POINT 2 POINT 2 POINT 2 POINT 2 POINT 2
}

and in the "child" or "popup" form I have:

<body onunload="SetUpCallingPage()">

<SCRIPT language="javascript" id="Custom2">
<!--
function SetUpCallingPage()
{
window.returnValue = 1;
}
//-->
</SCRIPT>

The problem I'm having is twofold.

Running as it is, when the pop-up is closed there is a postback of some
sort on the "parent" or "closing" form, but the code at
document.all.item("cmdFilter").click(); IS NOT CALLED - at least, the
breakpoint at the start of the code is not hit (unlike, say, if I click
on the button). Also, all the values that have been entered into the
criteria controls (month and year) are lost or, rather, reset to their
default values.

If I remove the code between POINT 1 and POINT 2, it all seems to work
well. The pop-up is displayed, the data can be manipulated in the
pop-up, but of course when the pop-up is closed the "parent" or
"calling" form is not refreshed or posted back to reflect changes to
the underlying data. However, unlike in the above scenario the
controls on the form remain unchanged.

I tried using location.reload(true); in place of the
document.all.item("cmdFilter").click(); but I got a message box which
the clients won't like. I've also tried saving the criteria to a group
of hidden controls and retrieving them in the code-behind, but since
the code behind doesn't seem to be hit by the

document.all.item("cmdFilter").click();

there's little likelihood that this will work.

Has anyone any ideas where I'm going wrong? It's driving me nuts!

Anyway, happy Christmas (or whatever) to all our readers.

Edward

Dec 23 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.