Get Child window values to parent using javascript

Madhu.b.rokkam
Posted by in ASP.NET category on for Beginner level | Points: 250 | Views : 19598 red flag
Rating: 5 out of 5  
 2 vote(s)

Through this article we will try to popup a child window and from there we will try to return a row data and populate into parent page using javascript.


 Download source code for Get Child window values to parent using javascript

Introduction

As per one of our DNF friend's requirement I am posting this blog on how to pass values from child window to parent using javascript.

Scenario.. Default.aspx will popup a child window Default2.aspx which will have grid containing some records on selecting some record the row values should be returned to the Parent window and populate the text boxes there. All this using Javascript.

So lets start ...

Open Visual studio create a new website and the default.aspx loads[ We will use this as Parent Page], Add one more page default2.aspx [Will use as Child Window]

Open the default.aspx page and design as shown below.

The source window will look like below

Add javascript file to popup the child window and capture the values sent by child window and assign to the text boxes.

In the code behind file attach the javascript function to the button

Now open the default2.aspx page and add one datagrid with one template column as shown below

Add one javascript function to set the values to send back to parent into an object and return on clicking the button. The source file will look as below.

And finally in the code behind attach the javascript function to the button.

And finally to populate the grid we have set an xml data as below

Build and run the app.

The default page loads, On clicking the show window button the pop up child window pops up and on selecting a record there brings up data from child to parent and populates the text boxes as shown below.




Conclusion

Hope you all will like this article and my DNF friend will use this. Please share your feedback and or comments.

Page copy protected against web site content infringement by Copyscape

About the Author

Madhu.b.rokkam
Full Name: Madhu Rokkam
Member Level: Bronze
Member Status: Member,MVP
Member Since: 1/13/2011 3:13:20 PM
Country: India
Thanks and Regards Madhu
http://www.dotnetfunda.com

Login to vote for this post.

Comments or Responses

Posted by: Gopal_nivas on: 2/23/2011 | Points: 25
hi madhu..

this article was helped me lot..
nice article..

regards
gopal.s
Posted by: Madhu.b.rokkam on: 2/23/2011 | Points: 25
Thanks Gopal for your comments.

I am glat that you got benefit out of this article..

Login to post response

Comment using Facebook(Author doesn't get notification)