Solved

Call a function in parent page from a popup

Posted on 2009-05-20
5
674 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 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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…

739 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