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
103 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

803 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