Open a view as a pop up

asp.net-mvc-3

Solution

Add a class to the link:

@Html.ActionLink("Download", "Download", new { id = model.Id }, 
                                         new{ @class = "dialog"} )

And add this script somewhere:

<script type="text/javascript">
    $(function (){
        $('a.dialog').click(function() {
            var url = $(this).attr('href');
            var dialog = $('<div style="display:none"></div>').appendTo('body');
            dialog.load(url, {}, 
                function (responseText, textStatus, XMLHttpRequest) {
                dialog.dialog({
                    close: function(event, ui) {
                        dialog.remove();
                    }
                });
            });
            return false;
        });
    });
</script>

Required CSS/JS

- jQuery UI: https://jqueryui.com/

Problem

Controller.cs is: ``` public ActionResult ViewRequest(int id) { Job job = Jobs.GetJob(id); return View(job); } ``` It's view is: ``` @model model.Job <fieldset> <legend>Job</legend> <div class="display-label">Name</div> <div class="display-field"> @Html.DisplayFor(model => model.Name) </div> </fieldset> @Html.ActionLink("Download", "Download", new { id = model.Id }) | ``` How do I open it as a model pop up

Original source