最近、3.7 sp4 プロジェクトを 5.2 に移行しましたが、移行中に問題が発生しました。現在、5.2 プロジェクトへの移行後、ユーザー コントロールが機能しません。
以下はコードです:
ユーザー制御コード:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SiteMenu.ascx.cs" Inherits="UserControls_Nav_SiteMenu" %>
<%@ Register TagPrefix="telerik" Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" %>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false" />
<telerik:RadMenu ID="RadMenu1" runat="server" DataSourceID="SitemapDataSource1" OnItemDataBound="RadMenu1_ItemDataBound">
</telerik:RadMenu>
ユーザー コントロールのクラス コード:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.ComponentModel;
using System.Drawing;
using Telerik;
using Telerik.Cms;
using Telerik.Cms.Web;
using Telerik.Web.UI;
using Telerik.Caching;
using Telerik.Cms.Web.UI;
[DefaultProperty("StartingNodeOffset")]
public partial class UserControls_Nav_SiteMenu : System.Web.UI.UserControl, ICacheableObject
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected override void Render(HtmlTextWriter writer)
{
// Checks if this is called by the Search Indexer and does not render anything if so.
// Navigation controls are present in every page and should NOT be indexed multiple times.
if (!CmsContext.IsRequestCrawler(this.Context))
base.Render(writer);
}
#region Data Fields
private bool hideUrlForGroupPages = false;
private string selectedItemCssClass = "selectedItem";
#endregion
#region Properties
[Browsable(true)]
[Category("Behavior")]
public int LastExpandLevel
{
get
{
if (this.RadMenu1.MaxDataBindDepth < 0)
return 0;
return this.RadMenu1.MaxDataBindDepth;
}
set
{
if (value == 0)
this.RadMenu1.MaxDataBindDepth = -1;
else
this.RadMenu1.MaxDataBindDepth = value;
}
}
[Browsable(true)]
[Category("Behavior")]
public int ExpandDelay
{
get
{
return this.RadMenu1.ExpandDelay;
}
set
{
this.RadMenu1.ExpandDelay = value;
}
}
[Browsable(true)]
[Category("Behavior")]
public bool ClickToOpen
{
get
{
return this.RadMenu1.ClickToOpen;
}
set
{
this.RadMenu1.ClickToOpen = value;
}
}
[Browsable(true)]
[Category("Behavior")]
[DefaultValue(false)]
public bool HideUrlForGroupPages
{
get
{
return this.hideUrlForGroupPages;
}
set
{
this.hideUrlForGroupPages = value;
}
}
[Browsable(true)]
[Category("Appearance")]
public string SelectedItemCssClass
{
get
{
return this.selectedItemCssClass;
}
set
{
this.selectedItemCssClass = value;
}
}
[Browsable(true)]
[Category("Appearance")]
public string CssClass
{
get
{
return this.RadMenu1.CssClass;
}
set
{
this.RadMenu1.CssClass = value;
}
}
[Browsable(true)]
public RadMenu Menu
{
get
{
return this.RadMenu1;
}
set
{
this.RadMenu1 = value;
}
}
[Browsable(true)]
[Category("Navigation")]
public int StartingNodeOffset
{
get
{
return this.SiteMapDataSource1.StartingNodeOffset;
}
set
{
this.SiteMapDataSource1.StartingNodeOffset = value;
}
}
[WebEditor("Telerik.Cms.Web.UI.UrlEditorWrapper, Telerik.Cms")]
[Browsable(true)]
[Category("Navigation")]
public string StartingNodeUrl
{
get
{
return this.SiteMapDataSource1.StartingNodeUrl;
}
set
{
this.SiteMapDataSource1.StartingNodeUrl = value;
}
}
[Browsable(true)]
[Category("Navigation")]
public bool StartFromCurrentNode
{
get
{
return this.SiteMapDataSource1.StartFromCurrentNode;
}
set
{
this.SiteMapDataSource1.StartFromCurrentNode = value;
}
}
[Browsable(true)]
[Category("Navigation")]
public bool ShowStartingNode
{
get
{
return this.SiteMapDataSource1.ShowStartingNode;
}
set
{
this.SiteMapDataSource1.ShowStartingNode = value;
}
}
/// <summary>(Exposed from contained RadMenu.)</summary>
[Browsable(true)]
[Category("Appearance")]
public string SkinID
{
get
{
return this.RadMenu1.SkinID;
}
set
{
this.RadMenu1.SkinID = value;
}
}
[Browsable(true)]
[Category("Appearance")]
public string Skin
{
get
{
return this.RadMenu1.Skin;
}
set
{
this.RadMenu1.Skin = value;
}
}
#endregion
#region Methods
public void RadMenu1_ItemDataBound(object sender, RadMenuEventArgs e)
{
CmsSiteMapNode node = e.Item.DataItem as CmsSiteMapNode;
if (this.hideUrlForGroupPages)
{
if (node != null)
{
// save the PageID in the attributes of the menu item
e.Item.Attributes.Add("PageID", node.Key);
if (node.PageType == CmsPageType.Group)
{
e.Item.NavigateUrl = "";
}
}
}
if (node.CmsPage != null)
{
if (node.CmsPage.PageType == CmsPageType.External)
{
e.Item.Target = "_blank";
}
}
}
#endregion
#region ICacheableObject Members
public System.Web.Caching.CacheDependency[] GetDependencies()
{
CmsSiteMapProvider provider = null;
if (!String.IsNullOrEmpty(this.SiteMapDataSource1.SiteMapProvider))
provider = SiteMap.Providers[this.SiteMapDataSource1.SiteMapProvider] as CmsSiteMapProvider;
else
provider = SiteMap.Provider as CmsSiteMapProvider;
if (provider != null)
{
return new System.Web.Caching.CacheDependency[]{ provider.CloneCacheDependency()};
}
return null;
}
#endregion
}
テンプレートを (管理者モードで) 編集すると、コントロールの場所に次のエラーが表示されます。
Both DataSource and DataSourceID are defined on 'RadMenu1'. Remove one definition.
Description: An unhandled exception occurred during
the execution of the current web request. Please review the stack trace
for more information about the error and where it originated in the
code.
Exception Details: System.InvalidOperationException: Both DataSource and DataSourceID are defined on 'RadMenu1'. Remove one definition.
Source Error:
An unhandled exception was generated during the execution of the current
web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: Both DataSource and DataSourceID are defined on 'RadMenu1'. Remove one definition.]
System.Web.UI.WebControls.DataBoundControl.ConnectToDataSourceView() +3234866
System.Web.UI.WebControls.DataBoundControl.OnLoad(EventArgs e) +28
System.Web.UI.Control.LoadRecursive() +71
System.Web.UI.Control.LoadRecursive() +190
System.Web.UI.Control.LoadRecursive() +190
System.Web.UI.Control.AddedControl(Control control, Int32 index) +11422584
System.Web.UI.Control.EnsureChildControls() +182
System.Web.UI.Control.PreRenderRecursiveInternal() +60
System.Web.UI.Control.PreRenderRecursiveInternal() +222
System.Web.UI.Control.PreRenderRecursiveInternal() +222
System.Web.UI.Control.PreRenderRecursiveInternal() +222
System.Web.UI.Control.PreRenderRecursiveInternal() +222
System.Web.UI.Control.PreRenderRecursiveInternal() +222
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4201
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
しかし、上記のようにコードで検索したところ、DataSourceID のみが定義されています。
私は何をすべきか?
ありがとう