Reputation: 2737
I am redirecting a popup in asp.net(not through javascript). My requirement is, when the user closes the popup, I need to perform some action on the main page. How could I do this in asp.net.
This is my code for redirecting,
if (Request.QueryString["DESC"].ToString() == "AAA")
{
Response.Redirect("Edit.aspx"','popup', 'statusbar=no,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,height=600,width=800');");
}
In Edit.aspx,
protected void Page_Unload(object sender,EventArgs e)
{
//This is loading when page is loaded. This did not work when page is closed.
}
Please suggest me any method. Assume that now the Edit.aspx popup is opened. When it is closed I want to perform some other functionality.
I tried with Page_Unload event. But this is being called when the popup is loaded and not when unloaded.
Upvotes: 1
Views: 1128
Reputation: 8923
You can open child window from parent using javascript as below:-
window.open('Child.htm','');
window.myfunction = function(){
}
Now when user clicks on close button of child window you can call your javascript function defined in parent page or execute enent referring to event of parent page :-
window.onunload = function (e) {
opener.myfunction (); //or
opener.document.getElementById('someid').innerHTML = 'update content of parent window';
};
But if you want to do it in asp.net(without javascript) you can follow below steps:-
1)Response.Redirect(DestinationPage.aspx)
2)Do manipulation on your DestinationPage nad redirect back to SourcePage with an
identifier in URL Response.Redirect(SourcePage.aspx?operation=myoperation)
3)Read value of operation
from QueryString
and do the operation as needed.
Upvotes: 2