пятница, 24 августа 2012 г.

ASP .NET MVC jQuery PopUp Windows from Partial View

One possibility is to use jquery ui dialog.
The idea would be to have an ajax action that returns a partial view. The result of that action (html) is placed inside the container of the popup and on the success handler of the ajax call you open the popup. Here is some sample code:
@Ajax.ActionLink("Open popup", "SomeAction", new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "result", InsertionMode = InsertionMode.Replace, OnSuccess="openPopup" })<br />
<div id="result" style="display:none;"></div>
<script type="text/javascript">
$(document).ready(function() {
        autoOpen: false,
        title: 'Title',
        width: 500,
        height: 'auto',
        modal: true
function openPopup() {
Then you have to add the action in the controller that returns the partial view
 public PartialViewResult SomeAction()
      return PartialView();
Place whatever you need in the partial view, you may also include parameters in the action, etc.
Good luck!

Комментариев нет: