angle

Passing values between a parent window and the popup window

This article is a followup to our article entitled "Opening popup windows in ASP.NET". Passing strings or values is a relatively straightforward matter using the querystring.  Make two new pages one will have the hyperlink control that launches the popup while the second is the popup page. Add the following code to to the codebehind in the Page Load of the parent page:
Hyperlink1.Attributes.Add("onclick", "window.open('popup.aspx',null,'height=250, width=250,status= no, resizable= no, scrollbars=no, toolbar=no,location=no,menubar=no ');")
 
Modify the url pop.aspx to read popup.aspx?Param=SomeString. Next in popup.aspx use the following code to get the string value and display it on the page:
Response.Write("You passed the value " & Request.Params("Param"))
 
Save all your pages. Build the project if you have need to. Clicking the hyperlink in the parent window now launches the popup which will display the value passed to it. Here's a demo.
 
One point about using the querystring to pass values to a popupwindow - this is not a secure way to pass information. Don't use this method to pass sensitive inormation such as user data (credit card numbers, passwords) to the popup window.