Solved

Call a function in parent page from a popup

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Calling stored proc in EDMX 11 23
Getting multiple values from a dataset ASP.NET(VB) 3 37
Syntax Error 2 42
Why is some text in blue in Visual Studio? 6 22
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
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 …
A short film showing how OnPage and Connectwise integration works.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

929 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

14 Experts available now in Live!

Get 1:1 Help Now