ReportViewer web form causes page freeze

I was asked to take a look at what should be a simple problem with one of our web pages for a small dashboard web app. This app is just showing some basic state information for basic backend applications that I work hard in. The problems are as follows:

On a page where a user can enter parameters and request to view a report with a given user, the button calls a JS function that opens a new page in the browser to display the report. The code looks like this:

$('#btnShowReport').click(function () {
    document.getElementById("Error").innerHTML = "";

    var exists = CheckSession();

    if (exists) {
        window.open('<%=Url.Content("~/Reports/Launch.aspx?Report=Short&Area=1") %>');
    }
});

      

The page being opened has the following code, which is called from Page_Load:

    rptViewer.ProcessingMode = ProcessingMode.Remote
    rptViewer.AsyncRendering = True
    rptViewer.ServerReport.Timeout = CInt(WebConfigurationManager.AppSettings("ReportTimeout")) * 60000
    rptViewer.ServerReport.ReportServerUrl = New Uri(My.Settings.ReportURL)
    rptViewer.ServerReport.ReportPath = "/" & My.Settings.ReportPath & "/" & Request("Report")

    'Set the report to use the credentials from web.config
    rptViewer.ServerReport.ReportServerCredentials = New SQLReportCredentials(My.Settings.ReportServerUser, My.Settings.ReportServerPassword, My.Settings.ReportServerDomain)
    Dim myCredentials As New Microsoft.Reporting.WebForms.DataSourceCredentials
    myCredentials.Name = My.Settings.ReportDataSource
    myCredentials.UserId = My.Settings.DatabaseUser
    myCredentials.Password = My.Settings.DatabasePassword
    rptViewer.ServerReport.SetDataSourceCredentials(New Microsoft.Reporting.WebForms.DataSourceCredentials(0) {myCredentials})

    rptViewer.ServerReport.SetParameters(parameters)

    rptViewer.ServerReport.Refresh()

      

I missed some code that creates parameters for the report, but I doubt it matters.

The problem is that when the user clicks the "show report" button and this new page opens, depending on the types of parameters they are using for the report, it can take quite a long time to render, while at the same time the original page becomes completely not responding. The moment the report page is actually displayed, the master page starts working again. Where do I start (google keywords, ReportViewer properties, etc.) if I want to fix this behavior so that another page can load asynchronously without affecting the master page?

Edit -

I tried to do the following, which was in the linked answer in a comment here:

            $.ajax({
                context: document.body,
                async: true,   //NOTE THIS
                success: function () { 
                    window.open(Address);
                }
            });

      

this replaced the call to window.open. It seems to work, but when I check the documentation trying to figure out what it does, I found this:

The .context property was deprecated in jQuery 1.10 and is only supported to the extent necessary to support .live () in the jQuery Migrate plugin. It may be removed without prior notice in a future version.

I removed the context property completely and it didn't seem to affect the code at all ... Can this ajax call be used in such a way to open another window or is there a better approach?

+3


source to share


3 answers


Using a timeout should open the window without blocking the main page



$('#btnShowReport').click(function () {
  document.getElementById("Error").innerHTML = "";

  var exists = CheckSession();

  if (exists) {
    setTimeout(function() {
      window.open('<%=Url.Content("~/Reports/Launch.aspx?Report=Short&Area=1") %>');
    }, 0);
  }
});

      

+2


source


This is a long shot, but did you first try to open a window with an empty url and change the location afterwards?



$("#btnShowReport").click(function(){
    If (CheckSession()) {
        var pop = window.open ('', 'showReport');
        pop = window.open ('<%=Url.Content("~/Reports/Launch.aspx?Report=Short&Area=1") %>', 'showReport');
    }
})

      

0


source


use

`$('#btnShowReport').click(function () {
 document.getElementById("Error").innerHTML = "";

 var exists = CheckSession();

 if (exists) {
     window.location.href='<%=Url.Content("~/Reports/Launch.aspx?Report=Short&Area=1")       %>';

 }
 });`

      

it will work.

-1


source







All Articles