目前我有一種將PDF加載到HTML頁面的方法。 PDF是從數據庫中檢索數據後動態創建的。現在,我想要做的是在加載PDF視圖之前,我想顯示一個讓用戶知道信息正在加載的頁面。將數據從控制器傳遞到視圖並返回到控制器
ActionParams:
@using (Html.BeginForm("PreLoaderView", "Report", FormMethod.Post, new {
@target = "_blank"
}))
控制器:
public ActionResult PreLoaderView(TestViewModel viewModel) {
return View(viewModel);
}
public ActionResult SolicitorActionReport_Load(TestViewModel viewModel) {
var cultivationModel = new CultivationModel(viewModel, ConstituentRepository, CampaignRepository);
var cultivationData = cultivationModel.GetCultivationActivityData();
var reportParamModel = new List<ReportParamModel>
{
new ReportParamModel() {AgencyName = SelectedUserAgency.AgencyName, StartDate = viewModel.StartDate, EndDate = viewModel.EndDate}
};
return FileContentPdf("Constituent", "CultivationActivityManagement", cultivationData, reportParamModel, new List<FundraisingAppealMassSummary>(), new List<FundraisingAppealPortfolioSummary>());
return Content(viewModel.SolicitorType);
}
PreLoaderView:
@model Report.SolicitorActionParamsViewModel
@{
ViewBag.Title = "Cultivation Activity";
}
<script type="text/javascript">
$(function() {
$.ajax({
url: '@Url.Action("SolicitorActionReport_Load", "Report", @Model)',
complete: function() {
$('#progress').hide();
},
error: function() {
alert('oops');
}
});
});
</script>
<div align="center">
<img id="progress" src="~/Content/images/loading.GIF">
<div id="result">
<embed width="100%" height="800px" src="http://localhost/YP/Report/SolicitorActionReport_Load"type="application/pdf">
</div>
</div>
所以,從PreLoaderView,我想通過@Model
回控制器與SolicitorActionReport_Load()
一起使用。這可能嗎?