目前我有一种将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()
一起使用。这可能吗?