Solved

Call a function in parent page from a popup

Posted on 2009-05-20
5
671 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
  • 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
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…

770 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