views:

1707

answers:

2

I'm looking for the simplest way of popping a modal search window on top of an ASP.NET 3.5 application to look up values for a field. I've got a screen for users to add courses; users need to be able to choose an instructor by searching for instructors in a popup.

So - the popup would have a textbox and a gridview with results; clicking the "choose" button in a result would populate the instructor field on the calling form.

What's the simplest way to achieve this?

+1  A: 

Try using jQuery inside a UserControl with something like the tutorial from yensdesign.

The UserControl I created with this approach provided the user the option to set their preferences for the site. I found with this approach it was easier to control the interaction between the modal window and the calling window than calling a new popup browser window. One also doesn't have to worry about popup blockers getting in the way.

Is this helpful or are you looking for more detail?

Tom
So the popup is not a separate window; it's a usercontrol embedded in the parent page?
Caveatrob
Yes, it's a hidden user control that is displayed over the page when appropriate. This is harder technically than using window.open though.
Tom
A: 

A very simple approach would be to add javascript to your page to popup a new browser window dialog, something like this:

function fnFieldSearch(searchURL)
{
    var wndSearch = window.open(searchURL,"SearchPopup","toolbar=yes,width=600,height=400,directories=no,status=yes,scrollbars=yes,resizable=yes,menubar=no");
    wndSearch.focus();
}

On the modal search page, use javascript to send the search value back:

window.opener.document.FormName.ControlName.value = 'whatever';
wweicker