Reputation: 467
My main page has a GridView
and Button
s for add/update. When I click the update button, a window pops up(used JavaScript
) which has input fields and a Button
for actually updating the record. What I want to know is how to refresh the main page when I click the update button inside the pop-up window.
This is the partial code of what I tried on actual update's OnClick
:
if (PreviousPage != null)
{
GridView gridv = (GridView)Page.PreviousPage.FindControl("GridView1");
gridv.DataBind();
}
While debugging, I realized that the if statement was never executed. Does that mean pop-up windows do not have a PreviousPage
initially? If so how can I reach the Main page then? (i shall note that the main page is not a master page)
This is how I create the pop-up on button click from the Main page(so it's a new window):
function btnEditEP_Click() {
var recID = document.getElementById('<%=tboxEdit.ClientID%>').value;
window.open("editPopupEP.aspx?Txt=" + recID, "_blank", "toolbar=yes", "resizable=yes", "scrollbars=yes");
}
Upvotes: 0
Views: 1727
Reputation: 1424
On the update click also perform the close pop up call
<script>
var popupWindow;
function openw(url) {
popupWindow = window.open(url, "popup", "");
}
function closew() {
if (popupWindow) {
popupWindow.close();
}
}
</script>
<a href="javascript:openw('about:blank')">open</a><br />
<a href="javascript:closew()">close</a>
like described here . How to close a popup window in a parent window?
and then in closw
you can call your parent page with true/false value depending on your update operation. You can use a hiddenfield
for this.
Upvotes: 0
Reputation: 478
On your child window you can call a function something like this in your child window call on your update function
<script type="text/javascript">
function MyFunction() {
window.opener.PostBackParentWindow();
window.close();
}
</script>
and in your parent window call add this code
<script type="text/javascript">
function PostBackParentWindow() {
__doPostBack(null, null);
}
</script>
Hope it might help
Upvotes: 2