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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Ajax control editor 4 34
Replacing HTML tags in Textarea/Textbox 5 26
Asp/Net Validation date Issue 9 38
ajax form sumbit 3 27
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now