Solved

Ajax ModalPopupExtender / iFrame - button to run some code, close the popup and rebind a dropdown on the parent

Posted on 2016-07-25
2
129 Views
Last Modified: 2016-08-30
I am trying to use an AjaxControlTookit ModalPopupExtender for the first  time.
A button on the parent page displays an asp.panel which contains an iFrame whose source is another aspx page.

When the user has finished with the popup, I'd like there to be button which:
1) causes some codebehind to write values to my database
2) closes the popup (equivalent to the "CancelControlID" button click action)
3) rebinds a dropdown on the parent page.

I can do 1) with a button on the child page firing codebehind.
I'm pretty sure I can do 2 and 3) with a button on the parent page mapped to the CancelControlID of the PopupExtender.

How can I do 1), 2) and 3)  with one button and which page does it need to be on?
Ideally, I'd prefer to do a partial page refresh of the parent page and just update the dropdown - there's a lot of delicate Ajax and Javascript stuff there which might otherwise be affected by a premature full postback of the page.
0
Comment
Question by:Beamson
2 Comments
 
LVL 12

Accepted Solution

by:
Ramkisan Jagtap earned 500 total points
ID: 41771517
If you are still looking for the answer:

You have to trigger the event that refreshes the target update panel from the popup.
One way of doing this is using the window.opener element.

Here is a simple example of code in a popup that you can adapt for your project.
 Note you'll need to change 'btnTriggersUpdate' to the ClientID that is given to whatever
 Button triggers the Update Panel refresh.

This will be the button on your child form in the iframe.
<asp:Button runat="server" ID="btnRefreshParentUpdatePanel" 
OnClientClick="window.opener.document.getElementById('btnTriggersUpdate').click();" 
Text="Refresh Parent Update Panel" />

Open in new window


Here is the Update Panel in the parent:

<asp:UpdatePanel ID="upnTarget" runat="server">
    <ContentTemplate>
        //Here will be you dropdown list
        <asp:Button ID="btnTriggersUpdate" runat="server" Text="Refreshes Update Panel" />
    </ContentTemplate>
</asp:UpdatePanel>  

Open in new window


Parent's btnTriggerUpdate_Click to prove it updates:
Protected Sub btnTriggersUpdate_Click(sender As Object, e As EventArgs) Handles btnTriggersUpdate.Click
    //Code to bind your dropdownlist
End Sub 

Open in new window

0
 
LVL 1

Author Closing Comment

by:Beamson
ID: 41776307
That does the trick.  The key was knowing about the windows.opener class as a means of referencing the parent page.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question