Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
After closing the window that means 'X' symbol click if any changes are there then only i want to refresh my parent page else not .
is it possible in javascript ?
if it is
please suggest me the possibility .
Posted

1. Add a Script Manager control to your child page (if it is not already there).
2. Now you can add two methods in your page : pageLoad() that runs when the page is loaded. and pageUnload() which runs when the page is closed.

3. In Parent document, Add a hidden input control like :

<input type="hidden" id="inpRefresh" value="0" />

4 In Child Page also add a hidden input control as follows :

<input type="hidden" id="inpRefreshParent" value="0" />

5. In child window page (aspx) , add javascript function "pageUnload" and in that, set a flag like value in parent document's hidden control as follows ,
<script type="test/javascript">

function pageUnload()
{
parent.document.getElementById('inpRefresh').value = document.getElementById('inpRefreshParent').value;

}
</script>

Now in the child page's server side method where you are doing some data saving operation, set value of this hidden input to '1'.

e.g. inpRefreshParent.Value = "1";

6. In parent page, say on a button click you are opening the child window.
Then that function should be like this :

function ShowChildPage()
{
window.showModalDialog( ChildPageurl, arguments, feature options);
if(document.getElementById('inpRefresh').value == '1')
{
document.getElementById('inpRefresh').value = '0';//reset the value
return true; //this will execute server side click event of the button //which you can reload the data
}
else
{
return false;
}
}

The code for the button that will open the child page will be like this:

<asp:button runat="server" id="btnShow" onclientclick="javascript:return ShpwChildPage();" onclick="btnShow_Click" xmlns:asp="#unknown" />


and the server side click event handler will be like this :

protected void btnShow_Click(object sender,EventArgs e)
{
//Reload data
}


Hope this helps you :)
 
Share this answer
 
v2
Comments
bpendem 26-Sep-12 6:02am    
Thank you so much ..
C#
var objWindow = window.open('asdf');
objWindow.location.reload();
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900