A useful procedure I've been developing over the past, while developing web forms, is invoking popup windows that allow me to select an item from a custom list of items (for instance, entity objecrs bound to a DataGrid). The client click event on an item (wether its a cell, row, div...) will then pass some kind of reference to its parent window for it to know what the selected item was and properly deal with it.
Keeping this approach in mind, you can invoke a popup window by using window.open(). This is a W3C standard method, and has 3 parameters:
Url: Optional. String that specifies the URL of the document to display. If no URL is specified, a new window with about:blank is displayed.
Name: Optional. String that specifies the name of the window. This name is used as the value for the TARGET attribute on a form or an anchor element.
Features: Optional. String that contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). You an see the list of supported features here.
For instance, the following line of Javascript code would open a 640x500 window, with no location, scrollbars, menubar, status bar and toolbar, named "myName":
function openSelectorWindow(url) {
window.open(url, 'selectorWindow', 'location=no,scrollbars=no,menubar=no,status=no,titlebar=no,toolbar=no,width=640,height=660', true);
return true;
}
The Window object has an "opener" property that references the parent window (the window that opened it). If a window has no parent, this will return null. So, in this newly opened browser window we can access its parent through the Window.Opener property. It will give you access to the parent window objects and javascript methods, allowing you to interact with it acoordingly to your needs.
If your parent window has the following javascript function:
function AlertMe() {
alert("I am executing on the parent window!");
}
It can then then be called by its child window like so:
window.opener.AlertMe();
Now that we know how to connect and interact with our parent window, we can now develop a more specific function to receive our selection parameters, like an ID:
function passArgs(id) {
document.getElementById('hiddenField').value = id;
}
And then, call it, like we did before on our AlertMe() example:
window.opener.passArgs(2);
Small example for those getting started into javascript.