User controls Stopped working after Migration from 3.7 to 5.2
- by user1400290
I recently Migrated my 3.7 sp4 project to 5.2, but I had issues while doing so.
Currently, my user controls are not working after migration in 5.2 project.
Below is the code:
User Control Code:
<%@ 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>
User Control's Class code:
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
}
When I edit the Template(in Admin mode), the following error is displayed in control location:
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
but I searched in my code as you can see above there's only DataSourceID is defined.
What should I do?
Thanks