Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Call a function in parent page from a popup

Posted on 2009-05-20
5
Medium Priority
?
678 Views
Last Modified: 2012-05-07
Hello Experts,

From my parent.aspx page I am opening popup.aspx on click of a button.
In popup.aspx after filling some details and hitting submit button can I call a function datagrid1.refresh()

I don't want to refresh the whole page. I just want to refresh the grid. This grid is in a user control.

Please help.
0
Comment
Question by:rowmark
[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
  • 3
  • 2
5 Comments
 
LVL 10

Expert Comment

by:MaxOvrdrv2
ID: 24433818
Hi,

I understand what you're trying to do... but i need more information on how you're opening the new page... are you using client side scripting? (JavaScript)

if so, there's a solution...

if not, then i would recommend putting the objects and functions that handle the @details@ gathering on the same page as your datagrid and simply show/hide it instead of opening a new window... because doing what you're asking all via server-side is really a big pain in the butt for no reason.
0
 

Author Comment

by:rowmark
ID: 24433908
Hi MaxOvrdrv2,
Thanks a ton for your response. I am opening the new window using the below mentioned code.
I would really appreciate your help
btAssign.Attributes.Add("onclick", "return jsPop('PopUp.aspx?CandidateId=" + candidateID + "', 320, 260);")

Open in new window

0
 
LVL 10

Expert Comment

by:MaxOvrdrv2
ID: 24434601
in that case, in the popup.aspx page, you can use the following to refer to a parent page control, and invoke its click event:

window.opener.document.getElementById("ParentHiddenControlThatWillFireTheRefreshAction").Click();
window.close();

note that this will cause a postback on the parent page... i don't think there is a client-side version for refreshing a datagrid.
0
 

Author Comment

by:rowmark
ID: 24435319
Thanks for your response. But it is not happening
I added a new button on my page
<asp:Button ID="btnRefreshGrid" runat="server" />  

In the code behind I have this
Protected Sub btnRefreshGrid_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRefreshCandidatesGrid.Click
Grid1.refreshGrid()
    End Sub

When I added
window.opener.document.getElementById("btnRefreshGrid").Click();
window.close();

In my popup page though it is closing window promptly it is not calling my btnRefreshGrid_Click event in the parent page.

0
 
LVL 10

Accepted Solution

by:
MaxOvrdrv2 earned 2000 total points
ID: 24440231
you will need to add a querystring to your popup page to get the client name of the object to click... ASP.Net assigns different names to objects at runtime than the ones you declare... so btnRefreshGrid, at runtime, becomes something like: cis01.c8tk.aspbuttonBtnRefreshGrid ... this is the name you want to use... so you have to pass the clientID to the popup, and use that in your javascript in the popup to fire the event.

in the main page:
 
btAssign.Attributes.Add("onclick", "return jsPop('PopUp.aspx?CandidateId=" + candidateID + "&BID=<%=Me.btnRefreshGrid.ClientID%>', 320, 260);")
 
in the popup page, on load (code-behind):
 
Me.HiddenTextBox.Text=Request.QueryString("BID")
 
Javascript:
window.opener.document.getElementById(""+document.getElementById("<%=Me.HiddenTextBox.ClientID%>").value).Click();
window.close();

Open in new window

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

664 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