Controller.cs是:
public ActionResult ViewRequest(int id) { Job job = Jobs.GetJob(id); return View(job); }
它的观点是:
@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 }) |
如何将其作为模型弹出窗口打开
解决方法
在链接中添加一个类:
@Html.ActionLink("Download",new { id = model.Id },new{ @class = "dialog"} )
并在某处添加此脚本:
<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>
必需的CSS / JS
> jQuery UI:https://jqueryui.com/