views:

620

answers:

3

I am writing an ASP.NET 3.5 web app that displays a list of items. I want to be able to display a non-modal popup with details when the user selects an item. I want to be able to display several detail popups simultaneously. (i.e., the user can click an item to see its details, then click another item to get another popup.) Currently I call RegisterStartupScript during postback to write a "window.open(...)" script to the page when it re-renders. The problem, of course, is that this requires a full page postback and refresh.

It occured to me that this might be a perfect use for XMLHttpRequest or AJAX but I don't know how to do it (or whether it's even possible or smart to do this). Can someone show me the way?

I have the AJAX Extensions installed but I'd prefer not to use the AJAX Control Toolkit.

Thanks

EDIT: Some clarification: When the user selects an item a custom event is raised. On the server I handle this event and use some server-side logic to construct a URL which I then use with RegisterStartupScript to construct a "window.open(myUrl...)" script. But posting back the whole page to do this seems inefficient and I'd like to know if I can just make a call to a simple server-side function that constructs the url and sends it back without having to roundtrip the entire page.

+1  A: 

Creating a popup has very little to do with AJAX, and a lot more to do with JavaScript. See the jQuery dialog library here. You can then use jQuery's AJAX API to do your server dirty work :)

jQuery Dialog UI

--

Bill Konrad
Devtacular - Web Development Tutorials

Bill Konrad
the sig and the advertising need to go, but it's a nice answer
annakata
Creating the popup window isn't the issue. What I'd like to know is whether I can process the user's selection on the server and then create the popup on the client without round-tripping the entire page.
Sisiutl
A: 

Do you really need to open a new window? Opening an absolutely positioned DIV or a new layer on top of the current page in the same window is all the rage these days.


Edit:

I don't think it would limit the number of popups, there is some neat stuff that can be done these days with libraries like jQuery + jQuery UI, you can simply create as many of these DIVs/layers as you need and make them movable, resizable, etc. Only thing that real popups have and these do not is that they do not appear on the tab panel/taskbar.

Yes, you will be limited to the size of the window in which is the main page opened, however, I don't personally see it as a problem since most people surf in a maximized browser window anyways.

Implementation of the oldschool typical popup window is undoubtedly much easier for you, but it also runs into problems with end user popup blockers. Just had that problem @ my work, they needed to make a popup during the certificate authentication process for some reason and as soon as Yahoo released a new version their toolbar, it quit working).

mike nvck
Won't this restrict me to just one detail popup at a time, and restrict the popup position to within the borders of the main page?
Sisiutl
A: 

You can use DHTML Window widget. It offers many way to display either modal or non modal window. Also it supports AJAX.

You can use dhtmlwindow for open a new window, or dhtmlmodal to open a new modal window.

Of course, you can edit it to match your requirement. Sample:

var insWindow = dhtmlmodal.open("insbox", "iframe","UserMaster.aspx?" + queryStr, "User Master", "width=425px,height=500,center=1,resize=0,scrolling=1", "recal");
Ahmed