Parent Page…

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

  '*****************************************************************************************************************

  'Building the client script- window.open, with additional parameters

  Dim ClientScript As String

  ClientScript = "window.open('PopUpPage.aspx','PopUp','width=350px,height=300px,left='+((screen.width -250) / 2)+',top='+                               (screen.height - 300) / 2+'');return false;"

  'regiter the script to the clientside click event of the 'opener' control

  cmdOpen.Attributes.Add("onClick", ClientScript)

'****************************************************************************************************************

End Sub

Popup Page…

Private Sub txtOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtOk.Click

 '***************************************************************************************

  'Close the windows and place the selected value in the Calling Form's Control.....

  'This is the name of the control, on the calling page, to place the selected value.

   Dim CallingPageControlToPlaceValue As String = "txtExamDate"

   Dim str As String = "<script>window.opener.document.forms[0]." + CallingPageControlToPlaceValue + ".value='" &                                 lstExamDate.SelectedItem.Text & "';self.close()</script>"

   RegisterClientScriptBlock("test", str)

 '***************************************************************************************

End Sub

 

 

 

Here’s a little more complcated version of the popup page script… It

  Updates more than 1 item from the calling page…

 

        Dim a() As String = Split(lstLev.SelectedItem.Value, " | ")

        Dim str As String

        If UBound(a) >= 0 Then

            str = "<script>window.opener.document.forms[0]." + "txtLev1" + ".value='" & a(0) & "';"

        Else

            str = "<script>window.opener.document.forms[0]." + "txtLev1" + ".value='" & " " & "';"

        End If

        If UBound(a) >= 1 Then

            str = str & "window.opener.document.forms[0]." + "txtLev2" + ".value='" & a(1) & "';"

        Else

            str = str & "window.opener.document.forms[0]." + "txtLev2" + ".value='" & " " & "';"

        End If

        str = str & "self.close()</script>"

        RegisterClientScriptBlock("test", str)