I’m working on a page, in which other pages are opened from it in a modal way. I need to call function exists in opener page to update certain controls in it.
I’m using window.open to open another window but in this case Page.PreviousPage for opened page is null.
I’m using
<%@ PreviousPageType VirtualPath='~/PreviousPage.aspx' %>
to refer to Previous Page.
Any suggestions?
FYI: all aspx pages are AJAX-Enabled.
You can’t call a method in the code behind of a
Pageclass to update controls in a page that is displayed. The instance of thePageclass only exists while the page is rendered, once the page is displayed in the browser, thePageobject no longer exists.The PreviousPage property is used when you make a post from one page to another, but it doesn’t contain the
Pageobject that was used to render the page, it contains a recreatedPageobject that will not be used to render anything at all. You can only use it to read information from the fields based on the information that was posted from it.If you want to update the opener page you either have to do it on the client side using Javascript (), or reload the page so that the server side code can repopulate it. A combination of them both would be to use AJAX to update the page.
Edit:
You can for example use Javascript to access the opener and change the content of an element:
You can also call a Javascript function in the opener page:
That which gives you more possibilities, like making an AJAX call to load data from the server.