views:

7483

answers:

3

I am looking for the most standard way to archive modal dialogs in ASP.NET MVC. An example of what I am trying to do is when I select an item from my "list" page, I want the "details" page to be a popup over the list and NOT a new page. I'm not looking for a hack. I want it to be a solution that follows the ASP.NET MVC pattern. I would also prefer not stepping outside jQuery and ASP.NET Ajax (no plugins UNLESS it is emerging as a best practice).

+8  A: 

The jQuery UI library has a dialog widget that I use for things like this. While it's a plugin, IMO, the best practice is simply not rolling your own dialog widget.

http://jqueryui.com/demos/dialog/

Lunchy
+3  A: 

Lunchy's dialog suggestion is nice. Just make an ajax request to your controller action and have the action return what you want to display, like a partial view with some formatting html. Then, put that html into your dialog, or whatever you plan to display, and show it.

scottm
I think I understand what you are saying. What would the "return" look like for the action method?
Brian David Berman
It looks just like any other action, your view just has some html to format the details. Then you use javascript/jQuery to display the html rendered either in a small window, or <div> or the dialog suggested.
scottm
Here is an example that show how to load external content into a jQuery dialog.http://www.christopherchin.com/blog/index.cfm/2009/3/19/jQuery--ajax-dialog--load-external-content
Andy
+3  A: 

One of the things that goes hand in hand with MVC is RESTful urls. That being the case the "standard" way of handling this would be to have the details pull up a new page with it's own, RESTful (and bookmarkable) URL instead of flying a dialog over the page. You could certainly do a "details preview" dialog within the context of the list, but if you're going to interact with the details, I'd consider doing a full request and get the details on it's own page.

tvanfosson