Asp.net-Mvc-3
作為彈出視窗打開視圖
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", "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 使用者界面:https ://jqueryui.com/