弹出窗口与消息在ASP.NET MVC应用程序

本文关键字:ASP NET MVC 应用程序 消息 窗口 | 更新日期: 2023-09-27 17:52:34

我在ASP工作。. NET MVC应用程序(razor),使用剑道UI。当客户点击按钮时,我应该显示一个报告。但是,报告不是那么快,我应该在弹出窗口中为客户端显示一条消息,类似于这样:"报告正在生成-稍后将出现一个带有结果的新窗口"。如何显示带有消息的弹出窗口?代码在哪里?请查看我使用的代码。按钮为:

<a class="k-button k-button-icontext k-grid-Patient" id="hrefAllCheckedPatientsRep" style="display:none;" href="#" onclick="getAllChecked();">Generate Report</a>&nbsp;

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();
            }
        });
        }

在Controller中我有一个Action:

    [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);
    }

等。

控制器中的另一个动作是:

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);
        }

弹出窗口与消息在ASP.NET MVC应用程序

使用下面的代码创建一个带有消息的div

<div id="effect" class="ui-widget-content ui-corner-all">    
<p>Loading Files...</p>
</div>

使用show function在javascript函数中显示弹出窗口

function getAllChecked() {$( "#effect" ).show( selectedEffect, options, 500, callback );}

在ajax success中隐藏弹出窗口

success: function (data) {
            if (data.success) {$( "#effect:visible" ).removeAttr( "style" ).fadeOut();}