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
144 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

Title # Comments Views Activity
asp.net mvc 2 44
Web Site Administration Tool - Security Questions 2 36
jquery autocomplete forcing the user to select an item from the list 7 63
Adding Rows to Grid 4 32
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Suggested Courses

732 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