如果提交按钮在@using Html.BeginForm 内,有没有办法打开一个新窗口?我尝试了以下但它不起作用?
@using (Html.BeginForm("SetCol", "Document", FormMethod.Post, new {target="_blank"})){
<div class="modal-body" data-height-relative="20">
.
.
.
</div>
<div class="modal-footer">
<div class="pull-right">
<input type="submit" value="Senden" class="btn btn-primary"/>
<a href="@ViewData["closeUrl"]" class="btn btn-primary" @(ViewData["closeUrl"] == "#" ? "data-dismiss=modal" : "")>@Translations.Close</a>
</div>
</div>
}
Run Code Online (Sandbox Code Playgroud)
输出是一个 PDF 文件:
<html>
<body marginwidth="0" marginheight="0" style="background-color: rgb(38,38,38)">
<embed width="100%" height="100%" name="plugin" src="http://localhost:54906/Document/SetCol?id=108" type="application/pdf">
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
下面的行适用于您的代码。可能与您的操作方法有关。
@using (Html.BeginForm("About", "Home", FormMethod.Post, new { target = "_blank" }))
Run Code Online (Sandbox Code Playgroud)
正如您在评论中提到的,此方法返回一个 PDF 文件,您可以像这样使用window.open:
window.open("../Document/SetCol", "_blank");
Run Code Online (Sandbox Code Playgroud)
或者
window.open("@Url.Action("LoadReport", "ExportReport")" + link, "_blank");
Run Code Online (Sandbox Code Playgroud)
显然,您必须定义一个单击事件处理程序。
归档时间: |
|
查看次数: |
5461 次 |
最近记录: |