Calling Page Code.  Place in Page_Load Event...

 

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

        'Place this code in the Calling Page's PAGE_LOAD Event. This code will setup the Onclick Attribute

        'of the OpenerControl,(CommandButton), to call the Popup page.

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

 

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

        '************** User defined variables ************************************************************************

        Dim strPopUp As String = "PopUp.aspx" 'Name of PopUp Page To Open

        Dim OpenerControl As WebControl = cmdSelect 'Name of Web Control, That When Clicked Will open the PopUp Window

        Dim iHeight As Integer = 300 'Height of Popup Window

        Dim iWidth As Integer = 300 ' Width of PopUp Window

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

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

 

        Dim JavaScript As String

        Dim windowAttribs As String

        windowAttribs = "width=" & iWidth & "px," & "height=" & iHeight & "px," & _

          "left='+((screen.width -" & iWidth & ") / 2)+'," & "top='+ (screen.height - " & iHeight & ") / 2+'"

 

        JavaScript = "window.open('" & strPopUp & "','" & "MyWindowName" & "','" & windowAttribs & "');return false;"

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

        OpenerControl.Attributes.Add("onClick", JavaScript)

 

        '********** End of code to appear in calling page's Page_Load Event ********************************************

 

 

 

Popup Page Code.  Place in "Return" button's Click Event...

 

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

'This code will return the value selected back to the calling page.  Place this code in the OnClick

'Event of the 'Return To Calling Page' Button on the Popup Page.

 

'***** User Defined Variable *************************************************************************

'Name of control, on the calling page, that will receive the information entered on this PopUp page.

 Dim strNameOfCallingPageControlToReceiveSelectedData As String = "txtReturnedValue"

'Name of control, on the popup page, that holds the information being returned to the calling page.

 Dim ReturnControl As WebControls.TextBox = txtValueToReturn

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

 

Dim strScript As String = ""

strScript = "<script>window.opener.document.forms[0]." + strNameOfCallingPageControlToReceiveSelectedData + ".value = '"

strScript = strScript & ReturnControl.Text

strScript = strScript & "';self.close()"

strScript = strScript & "</" + "script>"

RegisterClientScriptBlock("test", strScript)