CrystalReportViewer Broken Buttons Using MVC Framework

We use the MVC environment (version 5) and the CrystalReportViewer control to display our reports. I cannot get any of the buttons at the top of the report viewer to work.

If I work with the report "HoursSummary". If I hover over any of the buttons in the report viewer in IE, the link displayed at the bottom of the pages is "../HoursSummary". This creates the URL ' http: // localhost / HoursSummary '. There is no "HoursSummary" controller, so I get 404 errors.

  • I believe that I want to redirect to http: // localhost / reports / HoursSummary ', since I have a report controller. If this is the correct method, does anyone know what property I should set in the CrystalReportViewer control for this to happen?
  • Is there an easier way to deal with this situation?
+5
source share
2 answers

We were able to get the report viewer to work and use it over the past few months in production without any problems.

  • We have a report controller that lists the links to the reports we want to run.
  • , ajax- , .
  • "\ reports\Name of Report".
  • SQL, , " "
  • " " Crystal Report, , ViewData, , .

, , .

. , , - , Crystal Reports. , . Crystal Reports :

  • file.rpt,
  • aspx, Crystal Reports Report. , .

, , Crystal Reports:

  • Crystal Reports Designer. .rpt . AllJobsSummaryReportLayout.rpt.
  • " " - DTO, SQL.
  • (DTO) , , , DTO . , , DTO, , . DTO , , , , SQL, - .
  • Crystal Report, AllJobsSummaryReportLayout.rpt, . , , Model DTO, :

    var reportViewData = model.AllJobsSummaryQuery(startDate, endDate);
    if (0 != reportViewData.Count())
    {
        var report = new AllJobsSummaryReportLayout();
        report.SetDataSource(reportViewData);
        report.SetParameterValue("startDate", startDate);
        report.SetParameterValue("endDate", endDate);
        ViewData["ReportData"] = report;
        returnView = "AllJobsSummaryView";
    }
    else
        returnView = "noReportView";
    return View(returnView);
    
  • , varible 'report', Crystal Report AllJobsSummaryReportLayout.rpt, .

  • "report", , , ViewData.

  • AllJobsSummaryView.aspx. Crystal Reports Viewer , :

<%@ Page Title="All Jobs Summary Report" Language="C#" AutoEventWireup="true" CodeBehind="AllJobsSummaryView.aspx.cs" Inherits="V.Views.Reports.AllJobsSummaryView"%>     
<%@ Register Assembly="CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" Namespace="CrystalDecisions.Web" TagPrefix="CR" %> 
<form id="form1" runat="server">
<div>
<a href="/Reports" id="Report"><< Return to Report Main
    Page</a><br />
<CR:CrystalReportViewer ID="ReportViewer" runat="server" AutoDataBind="True" EnableDatabaseLogonPrompt="False"
    EnableParameterPrompt="False" HasCrystalLogo="False" DisplayGroupTree="False" 
    HasDrillUpButton="False" HasToggleGroupTreeButton="False" HasViewList="False" 
    HasSearchButton="False" EnableDrillDown="False" EnableViewState="True" 
    Height="50px" ReportSourceID="CrystalReportSource1" Width="350px" />    
<CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
    <Report FileName="AllJobsSummaryReportLayout.rpt">
    </Report>
</CR:CrystalReportSource>
</div>
</form>
  • :

     using System;
     using System.Collections.Generic;
     using System.Linq;
     using System.Web;
     using System.Web.Mvc;
    
     namespace V.Views.Reports
     {
        public partial class AllJobsSummaryView : ViewPage
        {
            protected void Page_Init(object sender, EventArgs e)
            {
                ReportViewer.ReportSource = ViewData["ReportData"];
            }
    
            protected void Page_Unload(object sender, EventArgs e)
            {
                ((AllJobsSummaryReportLayout)ViewData["ReportData"]).Close();
                ((AllJobsSummaryReportLayout)ViewData["ReportData"]).Dispose();
            }
        }
     }
    
  • _Unload , , Crystal Reports. " , ".

.

+3

, . ASP.NET MVC , - .

, iFrame MVC-. Iframe MVC, , Legacy - .

+3

All Articles