ReportViewer1在当前上下文中不存在
本文关键字:不存在 上下文 ReportViewer1 | 更新日期: 2023-09-27 18:29:50
我是ASP.NET的新手,正在尝试在我的网页上创建一个报表查看器对象。我需要将默认身份验证传递给服务器。我正在使用的代码可以在这里找到:http://msdn.microsoft.com/en-us/library/microsoft.reporting.webforms.ireportservercredentials.aspx?cs-保存lang=1&cs lang=csharp#code-snippet-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
检查.designer.cs文件并确保您的命名空间匹配,如果没有,则将其删除。这有时会让智能感知和/或构建器失去作用。