我是 ASP.NET 的新手,正在尝试在我的网页上创建一个报表查看器对象。我需要将默认身份验证传递给服务器。我正在使用的代码可以在这里找到:http: //msdn.microsoft.com/en-us/library/microsoft.reporting.webforms.ireportservercredentials.aspx ?cs-save-lang=1&cs-lang=csharp#code-片段 4
这是报表查看器的代码:
<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication3.WebForm1" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager runat="server"> </asp:ScriptManager>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" ProcessingMode="Remote" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
<ServerReport ReportPath="hoopstatist/Reports/Shooting Analysis" ReportServerUrl="https://rs2k1201.discountasp.net/reports" />
</rsweb:ReportViewer>
</div>
</form>
</body>
</html>
这是有错误的代码:
public partial class _Default : System.Web.UI.Page
{
protected void Page_Init(object sender, EventArgs e)
{
//It has issues here for ReportViewer1
ReportViewer1.ServerReport.ReportServerCredentials =
new MyReportServerCredentials();
}
}
这是错误:
Error 1 The name 'ReportViewer1' does not exist in the current context c:\users\nile\documents\visual studio 2012\Projects\WebApplication3\WebApplication3\WebForm1.aspx.cs 18 9 WebApplication3