Quantcast
Viewing all articles
Browse latest Browse all 3636

Crystal Report does not load on page refresh (.Net 4.0, VS2010, CRVS2010)

I am in the process of upgrading my web application. Here's the new configuration that I intend to use:

Windows Server 2008 R2, IIS 7, Visual Studio 2010, IE 8, ASP.Net 4.0, Ajax for .Net 4.0, Crystal Reports for Visual Studio 2010

 

I have a Crystal Report inside an update panel of Ajax on an ASP.Net web page. The report loads fine the first time; but when I change the filter criteria, a page refresh happens and the page goes blank. All of this happens in VS2010 on my development machine.

I checked the View Source of the returned HTML and seems like the report is there; but is not shown.  I also checked the visibility of the report in my code and it is visible.

 

I checked this link and tried everything there too - http://scn.sap.com/community/crystal-reports-for-visual-studio/blog/2012/10/16/report-appears-blank-in-browser-after-deploying-a-crystal-reportsnet-web-application

 

Here's the code that I use to load the crystal report. This same code worked perfectly fine with .Net 2.0 and CR For VS2005.

 

 

====== HTML for Crystal Report Viewer =========

<!-- The below code is inside an Ajax TabContainer -->

 

<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" HyperlinkTarget="_blank"
    ShowAllPageIds="True" Font-Bold="True" ToolbarStyle-CssClass="CRDisplayBar" EnableParameterPrompt="False"
    AutoDataBind="False" EnableDatabaseLogonPrompt="False" HasToggleGroupTreeButton="False"
    EnableDrillDown="False" ToolPanelView="None" ReuseParameterValuesOnRefresh="true" />

 

======= ASP.Net Code ========
protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
           scriptManager.RegisterPostBackControl(CrystalReportViewer1);
    SetReportViewerProperties(CrystalReportViewer1);
           
        }
        catch (Exception ex)
        {
            // Exception handling code
        }
    }


protected void SetReportViewerProperties(CrystalDecisions.Web.CrystalReportViewer crViewer)
    {
        ReportDocument rd = LoadReport(strReportName);

        if (rd.IsLoaded)
        {
            crViewer.Visible = true;
            crViewer.ReportSource = rd;
            Session["crViewer"] = crViewer;
        }
        else
        {
            crViewer.Visible = false;
        }

        crViewer.DisplayToolbar = true;
        crViewer.EnableParameterPrompt = false;
        crViewer.HasToggleGroupTreeButton = false;
        //crViewer.DisplayGroupTree = false;
        crViewer.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;
        crViewer.HasCrystalLogo = false;
        crViewer.HasDrillUpButton = false;
        crViewer.HasRefreshButton = false;
    }


protected ReportDocument LoadReport(string reportPath)
    {
        //rd = new ReportDocument();
        try
        {
            if (Session["rd"] == null)
            {
                rd = new ReportDocument();
                Session["rd"] = rd;
            }
            else
            {
                rd = (ReportDocument)Session["rd"];
            }

     // Some custom code...

            rd.Load(Server.MapPath(reportPath)); // reportPath contains the path of the Crystal Report
     rd.SetDataSource(myCustomDataSet);           

        }
        catch (Exception e)
        {
            // Exception handling code
        }
        return rd;
    }

 

 

================================

 

Am I missing something?

Please let me know if more information is required.


Viewing all articles
Browse latest Browse all 3636

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>