【发布时间】:2017-12-05 20:55:54
【问题描述】:
我正在尝试在模式窗口中打开 pdf 我遇到了问题
<div class="modal fade" id="basic" tabindex="-1" role="basic" aria- hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria- hidden="true">
</button>
</div>
<div class="modal-body">
<iframe id="Iframe1" src="" runat="server" width="540" height="600"></iframe>
</div>
<div class="modal-footer">
<button type="button" class="btn red btn-outline" data- dismiss="modal">
أغلق</button>
</div>
</div>
<!-- /.modal-content -->
</div>
</div>
我给iframe一个src来显示一个pdf文件,
frame1.Attributes.Add("src", "~/file.pdf");
问题是下载管理器强制文件下载而不出现在模式中, 所以我尝试添加下面的代码,但它在所有页面中都打开而不是模式
string x ="~/file.pdf";
Response.ContentType = "Application/pdf";
Response.WriteFile(HttpUtility.HtmlEncode(x));
Response.End();
frame1.Attributes.Add("src", x);
【问题讨论】:
标签: c# asp.net pdf iframe bootstrap-modal