Get Child window values to parent using javascript

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. 
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