Solved

Call a function in parent page from a popup

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
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 …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 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

19 Experts available now in Live!

Get 1:1 Help Now