我的智慧结束了。我正在尝试使用有效的aspx代码和ReportViewerForMVC代码来加载ReportViewer。首先,错误传播:
未捕获的SyntaxError:意外的令牌< WebResource.axd:1
未捕获的SyntaxError:意外的令牌< GetSysWideQuizReport:67
未捕获的ReferenceError:未定义ReportViewerForMvc(匿名 函数)@ GetSysWideQuizReport:67 Uncaught SyntaxError:Unexpected 令牌< ScriptResource.axd:1
未捕获的SyntaxError:意外的令牌< ReportViewerWebForm.aspx:40
未捕获错误:ASP.NET Ajax客户端框架失败 load。(匿名函数)@ ReportViewerWebForm.aspx:40 ScriptResource.axd:1
未捕获的SyntaxError:意外的令牌< ScriptResource.axd:1
未捕获的SyntaxError:意外的令牌< Reserved.ReportViewerWebControl.axd:1
未捕获的SyntaxError:意外的令牌< ScriptResource.axd:1
未捕获的SyntaxError:意外的令牌< ReportViewerWebForm.aspx:51
未捕获的ReferenceError:未定义系统(匿名函数)@ ReportViewerWebForm.aspx:51 ReportViewerWebForm.aspx:114
未捕获的ReferenceError:未定义Sys ReportViewerWebForm.aspx:114
观点:
@using ReportViewerForMvc;
@using Microsoft.Reporting.WebForms;
@using App.Models;
<style>
iframe{
width:900px;
}
</style>
@{
ViewBag.Title = "LocalReportExample";
}
<h2>Local report example</h2>
@Html.ReportViewer(ViewBag.ReportViewer as Microsoft.Reporting.WebForms.ReportViewer)
控制器:
public ActionResult GetSysWideQuizReport([Bind(Include = "Topic, Date1, Date2")] QuizReporting quizParams)
{
ReportViewer reportViewer = new ReportViewer();
reportViewer.ProcessingMode = ProcessingMode.Local;
reportViewer.SizeToReportContent = true;
reportViewer.Width = Unit.Percentage(100);
reportViewer.Height = Unit.Percentage(100);
reportViewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"/ReportViews/System Quiz Report.rdlc";
reportViewer.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", QuizData(quizParams)));
ViewBag.ReportViewer = reportViewer;
return View();
}
private DataTable QuizData(QuizReporting quizParams)
{
DataSet ds = new DataSet("DataSet1");
using(SqlConnection connection = new SqlConnection())
{
connection.ConnectionString = GetConnectionString();
SqlCommand cmd = new SqlCommand("SystemQuizReport", connection);
cmd.Parameters.AddWithValue("@TopicID", quizParams.Topic.TopicID);
cmd.Parameters.AddWithValue("@Date1", "2015/04/13");
cmd.Parameters.AddWithValue("@Date2", "2015/04/16");
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
da.Fill(ds);
return ds.Tables[0];
}
}
static private string GetConnectionString()
{
return "Data Source=(localdb)\\v11.0; Initial Catalog=LocalDb-20140822124213; Integrated Security=True;";
}
web.config的摘录:
<system.web>
<httpHandlers>
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" validate="false" />
</httpHandlers>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5">
<buildProviders>
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</buildProviders>
</compilation>
<httpRuntime targetFramework="4.5" />
<!--<hostingEnvironment shadowCopyBinAssemblies="false" /> -->
</system.web>
<system.webServer>
<modules>
<remove name="FormsAuthentication" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</handlers>
</system.webServer>
我已完成以下操作来修复它:
我把头发拉得这么多,所以我希望你能帮助我!