Click here to Skip to main content
12,632,234 members (26,810 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET Javascript
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 23-Sep-12 22:38pm
bpendem316
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

var objWindow = window.open('asdf');
objWindow.location.reload();
  Permalink  
v3
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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 :)
  Permalink  
v2
Comments
bpendem 26-Sep-12 6:02am
   
Thank you so much ..

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161208.2 | Last Updated 26 Sep 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100