Link to home
Start Free TrialLog in
Avatar of digital_soul
digital_soul

asked on

Force Postback of parent page from Thickbox IFrame window

Hi Experts

I have a bound gridview where each row has a link to open a modal window displaying a bound detailsview relating tot he selected row. I have been playing around with the modalpopupextender control, but have a number of issues getting that working without unneccesary post backs.

As a result I've tried just using a JQuery extension like Thickbox and opening an IFrame Modal window. This allows me to open a seperate aspx page fromw hich I can display the detailsview, bind it and allow for editing etc.. without any impact on the parent page.

The main problem with this is when I edit and save the detailsview I want to be able to update the gridview on the parent page (specifically to update the selected row to reflect any changes made to that record).

Is there any way of being able to send a response back to the parent page and either initiate a postback or partial postback based on an event in the thickbox child page?

Cheers

Stewart
Avatar of sagir
sagir

Hi,

Please try the following:

//Add this javascript
<script language="javascript">
function RefreshParent()
{
         window.parent.location.href = window.parent.location.href;
}
</script>

//then from code behind call this:
ClientScript.RegisterStartupScript(this.GetType(), "RefreshParent", "<script language='javascript'>RefreshParent()</script>");

tell me if it worked...
Avatar of digital_soul

ASKER

That causes the parent page to refresh  as opposed to postback (IsPostback is False when it happens), although now I realise that actually what I want to do is update the contents of the Update Panel (which contains the gridview) on the parent page  rather than post back the entire page to make the process appear more transparent. Is there a way of forcing the gridview to rebind and postback only the update panel?

ASKER CERTIFIED SOLUTION
Avatar of sagir
sagir

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Presumably then the Javascript function would need to be on the parent page, so how would I go about calling that from the Thickbox page?
window.parent.jsfunction(); should do it
I was thinking that going the JQuery Route over the modalpopupextender route would be a bit clunky, but actually this solution seems to work great.

I can open an IFrame modal window withy no extra postbacks on the master page and then only force a partial postback on the master page if content is updated in the Thickbox window. From a performance perspective this seems good and the user experience is fairly smooth too.
For reference my code is:

On aspx page displaying in thickbox

<script type="text/javascript">
        function RefreshParent()
        {
            window.parent.updateGrid();
            self.parent.tb_remove();
        }
    </script>

and in parent page

<script type="text/javascript">
        function updateGrid() {
            var btn = document.getElementById("<%= btnRefreshGrid.ClientID %>");
            btn.click();
        }
 </script>

Protected Sub btnRefreshGrid_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRefreshGrid.Click
        BindGrid()
    End Sub