我的一些网页遭受了这种情况,因为我在ascx中使用了属于ascx.cs的对象
这是我的ascx.cs:
public AnnouncementDetailItem announcement = new AnnouncementDetailItem();
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
InitializeControl();
}
protected void Page_Load(object sender, EventArgs e)
{
try
{
string qry ="...";
SPListItem spListItems = BaseSPList.GetItems(ListName, qry)[0];
if (spListItems != null)
{
announcement = new AnnouncementDetailItem() {
Title = spListItems.Fields["Title"].ToString(),
SubTitle = spListItems["SubTitle"].ToString(),
Content = spListItems["Content"].ToString(),
BroadcastDate = spListItems["BroadcastDate"].ToCustomDateTime(),
};
}
}
catch (Exception ex)
{
CoreException.WriteToLog("Announcements WP", ex);
}
}
ascx页面(即使我删除了这些内容仍然会发生同样的错误):我也分享了名称空间,如果它的原因导致了对不起。
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AnnouncementDetail.ascx.cs" Inherits="MaliyeWebPortal.WebParts.AnnouncementDetail.AnnouncementDetail" %>
<%@ Import Namespace="MaliyeCore.DTO" %>
<% if(announcement != null){ %>
<div id="announcementsTabs">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"> <a role="tab" data-toggle="tab" href="#duyuru<%=announcement.ID%>"><%=announcement.Title %></a></li>
</ul>
</div>
<% } %>
我该如何解决?