Hi,
My situation is, I have two aspx pages, parent and child. The parent has a gridview and a button, both of them have been placed inside ajax update panel. Once user click the button from parent.aspx, it open a popup window (child) and let user insert new record for parent gridview. The child.aspx has a insert button, what I want is, once user click the insert button, it close the child.aspx and post the new record back to parent gridview, or only refresh the gridview.
I am new to javascript, this is my code:
parent.aspx
<
script type="text/javascript"> function openWindow(gridviewId, datasource)
{
var windowUrl = 'child.aspx?gridviewId=' + gridviewId + '&datasource=' + datasource ; // datasource is the name of SqlDataSource
var windowName = 'Popup_' + new Date().getTime();var windowFeatures =
'channelmode=no,directories=no,fullscreen=no,' +'location=yes,dependent=yes,menubar=no,resizable=no,scrollbars=yes,' +
'status=no,toolbar=no,titlebar=no,' +'left=0,top=0,width=500px,height=500px';
window.open(windowUrl, windowName, windowFeatures);
}
function updateParent(gridviewId, sourceId)
{
var grid = document.getElementById(gridviewId);
grid.set_dataSource(sourceId);
grid.dataBind();
}
</script>
child.aspx
<
script type="text/javascript">
function closeWindow()
{
var gridviewId = '<%= Request["gridviewId"].ToString() %>';var source = '<%= Request["datasource"].ToString() %>';
window.opener.updateParent(gridviewId, source);
window.close();
}
</script>
....
<
asp:Button ID="btnInsert" runat="server" Text="Insert" OnClientClick="closeWindow()" />
The problem is, I can open popup from the parent.aspx, but when I click insert from child.aspx, the popup window can not get closed and nothing happend to my parent.aspx.