ASP.NET MVC modal dialog/popup best practice

Jqueryasp.net Mvcasp.net AjaxModal Dialog

Jquery Problem Overview


I am looking for the most standard way to achieve 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).

Jquery Solutions


Solution 1 - Jquery

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/

Solution 2 - Jquery

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.

Solution 3 - Jquery

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBrian David BermanView Question on Stackoverflow
Solution 1 - JqueryCasey WilliamsView Answer on Stackoverflow
Solution 2 - JqueryscottmView Answer on Stackoverflow
Solution 3 - JquerytvanfossonView Answer on Stackoverflow