-2
私は剣道UIを使用するASP.NET MVCアプリケーション(かみそり)で作業します。顧客がボタンをクリックしたときにレポートを表示する必要があります。しかし、レポートはあまり速くはないので、クライアントのポップアップウィンドウに「レポートが生成されました - 一瞬で新しいウィンドウが表示されます」というようなメッセージを表示する必要があります。ポップアップウィンドウにメッセージを表示するにはどうすればいいですか?コードのどこに?私が使用しているコードを見てください。ボタンです:ASP.NET MVCアプリケーションでポップアップウィンドウ
<a class="k-button k-button-icontext k-grid-Patient" id="hrefAllCheckedPatientsRep" style="display:none;" href="#" onclick="getAllChecked();">Generate Report</a>
これはJavaScriptでgetAllChecked機能()です:私はアクションを持っているコントローラーで
function getAllChecked() {
$('#checkedMsgRep').text('');
$.ajax({
type: "POST",
url: "/PatientReport/ExportToPDF",
dataType: "json",
traditional: true,
data: { uniqueIds: checkedArray },
success: function (data) {
if (data.success) {
// $('#lnkPdfDownload').show();
//$('#lnkPdfDownload').attr('href', '/PatientReport/DownloadFile' + '?fName=' + data.fName);
$('#myFrame').attr('src', '/PatientReport/DownloadFile' + '?fName=' + data.fName);
} else {
//$('#lnkPdfDownload').hide();
}
},
error: function (jqXHR, textStatus, errorThrown) {
$('#checkedMsgRep').text('@ELSORegistry.Resources.Views.Patient.PatientStrings.CheckedError').show();
$('#hrefCheckedPatientsRep').blur();
}
});
}
:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult ExportToPDF(List<String> uniqueIds) {
// step 1: creation of a document-object
var document = new Document(PageSize.A4.Rotate(), 3, 3, 80, 50);
//Here is the code for export to pdf
// Add table to the document
document.Add(dataTable);
//This is important don't forget to close the document
document.Close();
byte[] byteInfo = output.ToArray();
output.Write(byteInfo, 0, byteInfo.Length);
output.Position = 0;
var fName = string.Format("File-{0}.pdf", DateTime.Now.ToString("s"));
Session[fName] = output;
return Json(new { success = true, fName }, JsonRequestBehavior.AllowGet);
}
など
Contollerの他のアクションは:
public ActionResult DownloadFile(string fName)
{
var ms = Session[fName] as MemoryStream;
if (ms == null)
return new EmptyResult();
Session[fName] = null;
return File(ms, "application/pdf", fName);
}
提案:ポップアップを使用する代わりに、簡単に表示したり隠すことができる読み込み用のGIFイメージを使用してみませんか?単純なjQueryを使用して、レポート生成ボタンのクリックと非表示に成功を隠すために画像を表示することができます。 –
ありがとう、それはうまく動作します:) – alenan2013