REPOST: Need to refresh page after calling showModalDialog

T

teddysnips

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,toolbar=no,menubar=no,resiz­able=no,location=no,scrollbars=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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top