{"id":1948,"date":"2022-08-30T15:20:47","date_gmt":"2022-08-30T15:20:47","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/12\/05\/user-controls-stopped-working-after-migration-from-3-7-to-5-2-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:20:47","modified_gmt":"2022-08-30T15:20:47","slug":"user-controls-stopped-working-after-migration-from-3-7-to-5-2-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/user-controls-stopped-working-after-migration-from-3-7-to-5-2-collection-of-common-programming-errors\/","title":{"rendered":"User controls Stopped working after Migration from 3.7 to 5.2-Collection of common programming errors"},"content":{"rendered":"<p>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.<\/p>\n<p>Below is the code:<\/p>\n<p>User Control Code:<\/p>\n<pre><code>\n\n\n\n\n\n<\/code><\/pre>\n<pre><code>using System;\nusing System.Data;\nusing System.Configuration;\nusing System.Collections;\nusing System.Web;\nusing System.Web.Security;\nusing System.Web.UI;\nusing System.Web.UI.WebControls;\nusing System.Web.UI.WebControls.WebParts;\nusing System.Web.UI.HtmlControls;\nusing System.ComponentModel;\nusing System.Drawing;\n\nusing Telerik;\nusing Telerik.Cms;\nusing Telerik.Cms.Web;\nusing Telerik.Web.UI;\nusing Telerik.Caching;\nusing Telerik.Cms.Web.UI;\n\n\n[DefaultProperty(\"StartingNodeOffset\")]\npublic partial class UserControls_Nav_SiteMenu : System.Web.UI.UserControl, ICacheableObject\n{\n    protected void Page_Load(object sender, EventArgs e)\n    {\n\n    }\n\n\n    protected override void Render(HtmlTextWriter writer)\n    {\n        \/\/ Checks if this is called by the Search Indexer and does not render anything if so.\n        \/\/ Navigation controls are present in every page and should NOT be indexed multiple times.\n        if (!CmsContext.IsRequestCrawler(this.Context))\n            base.Render(writer);\n    }\n\n    #region Data Fields\n\n    private bool hideUrlForGroupPages = false;\n    private string selectedItemCssClass = \"selectedItem\";\n\n    #endregion\n\n    #region Properties\n\n\n\n    [Browsable(true)]\n    [Category(\"Behavior\")]\n    public int LastExpandLevel\n    {\n        get\n        {\n            if (this.RadMenu1.MaxDataBindDepth &lt; 0)\n                return 0;\n            return this.RadMenu1.MaxDataBindDepth;\n        }\n        set\n        {\n            if (value == 0)\n                this.RadMenu1.MaxDataBindDepth = -1;\n            else\n                this.RadMenu1.MaxDataBindDepth = value;\n        }\n    }\n\n\n    [Browsable(true)]\n    [Category(\"Behavior\")]\n    public int ExpandDelay\n    {\n        get\n        {\n            return this.RadMenu1.ExpandDelay;\n        }\n        set\n        {\n            this.RadMenu1.ExpandDelay = value;\n        }\n    }\n\n\n    [Browsable(true)]\n    [Category(\"Behavior\")]\n    public bool ClickToOpen\n    {\n        get\n        {\n            return this.RadMenu1.ClickToOpen;\n        }\n        set\n        {\n            this.RadMenu1.ClickToOpen = value;\n        }\n    }\n\n\n    [Browsable(true)]\n    [Category(\"Behavior\")]\n    [DefaultValue(false)]\n    public bool HideUrlForGroupPages\n    {\n        get\n        {\n            return this.hideUrlForGroupPages;\n        }\n        set\n        {\n            this.hideUrlForGroupPages = value;\n        }\n    }\n\n\n    [Browsable(true)]\n    [Category(\"Appearance\")]\n    public string SelectedItemCssClass\n    {\n        get\n        {\n            return this.selectedItemCssClass;\n        }\n        set\n        {\n            this.selectedItemCssClass = value;\n        }\n    }\n\n\n    [Browsable(true)]\n    [Category(\"Appearance\")]\n    public string CssClass\n    {\n        get\n        {\n            return this.RadMenu1.CssClass;\n        }\n        set\n        {\n            this.RadMenu1.CssClass = value;\n        }\n    }\n\n\n    [Browsable(true)]\n    public RadMenu Menu\n    {\n        get\n        {\n            return this.RadMenu1;\n        }\n        set\n        {\n            this.RadMenu1 = value;\n        }\n    }\n\n\n    [Browsable(true)]\n    [Category(\"Navigation\")]\n    public int StartingNodeOffset\n    {\n        get\n        {\n            return this.SiteMapDataSource1.StartingNodeOffset;\n        }\n        set\n        {\n            this.SiteMapDataSource1.StartingNodeOffset = value;\n        }\n    }\n\n\n    [WebEditor(\"Telerik.Cms.Web.UI.UrlEditorWrapper, Telerik.Cms\")]\n    [Browsable(true)]\n    [Category(\"Navigation\")]\n    public string StartingNodeUrl\n    {\n        get\n        {\n            return this.SiteMapDataSource1.StartingNodeUrl;\n        }\n        set\n        {\n            this.SiteMapDataSource1.StartingNodeUrl = value;\n        }\n    }\n\n\n    [Browsable(true)]\n    [Category(\"Navigation\")]\n    public bool StartFromCurrentNode\n    {\n        get\n        {\n            return this.SiteMapDataSource1.StartFromCurrentNode;\n        }\n        set\n        {\n            this.SiteMapDataSource1.StartFromCurrentNode = value;\n        }\n    }\n\n\n    [Browsable(true)]\n    [Category(\"Navigation\")]\n    public bool ShowStartingNode\n    {\n        get\n        {\n            return this.SiteMapDataSource1.ShowStartingNode;\n        }\n        set\n        {\n            this.SiteMapDataSource1.ShowStartingNode = value;\n        }\n    }\n\n    \/\/\/ (Exposed from contained RadMenu.)\n    [Browsable(true)]\n    [Category(\"Appearance\")]\n    public string SkinID\n    {\n        get\n        {\n            return this.RadMenu1.SkinID;\n        }\n        set\n        {\n            this.RadMenu1.SkinID = value;\n        }\n    }\n\n\n    [Browsable(true)]\n    [Category(\"Appearance\")]\n    public string Skin\n    {\n        get\n        {\n            return this.RadMenu1.Skin;\n        }\n        set\n        {\n            this.RadMenu1.Skin = value;\n        }\n    }\n\n    #endregion\n\n    #region Methods\n\n    public void RadMenu1_ItemDataBound(object sender, RadMenuEventArgs e)\n    {\n    CmsSiteMapNode node = e.Item.DataItem as CmsSiteMapNode;\n\n        if (this.hideUrlForGroupPages)\n        {\n\n            if (node != null)\n            {\n                \/\/ save the PageID in the attributes of the menu item\n                e.Item.Attributes.Add(\"PageID\", node.Key);\n\n                if (node.PageType == CmsPageType.Group)\n                {\n                    e.Item.NavigateUrl = \"\";\n                }\n\n            }\n        }\n\n        if (node.CmsPage != null)\n        {\n            if (node.CmsPage.PageType == CmsPageType.External)\n            {\n                e.Item.Target = \"_blank\";\n            }\n        }\n    }\n\n    #endregion\n\n    #region ICacheableObject Members\n\n    public System.Web.Caching.CacheDependency[] GetDependencies()\n    {\n        CmsSiteMapProvider provider = null;\n        if (!String.IsNullOrEmpty(this.SiteMapDataSource1.SiteMapProvider))\n            provider = SiteMap.Providers[this.SiteMapDataSource1.SiteMapProvider] as CmsSiteMapProvider;\n        else\n            provider = SiteMap.Provider as CmsSiteMapProvider;\n        if (provider != null)\n        {\n            return new System.Web.Caching.CacheDependency[]{ provider.CloneCacheDependency()};\n        }\n        return null;\n    }\n\n    #endregion\n}\n<\/code><\/pre>\n<p>When I edit the Template(in Admin mode), the following error is displayed in control location:<\/p>\n<pre><code>Both DataSource and DataSourceID are defined on 'RadMenu1'.  Remove one definition. \n\n\n\nDescription: An unhandled exception occurred during \nthe execution of the current web request. Please review the stack trace \nfor more information about the error and where it originated in the \ncode.\n\n\n\n\n\nException Details: System.InvalidOperationException: Both DataSource and DataSourceID are defined on 'RadMenu1'.  Remove one definition.\n\n\n\nSource Error: \n\n\n\n\n\n\n\n\nAn unhandled exception was generated during the execution of the current\nweb request. Information regarding the origin and location of the \nexception can be identified using the exception stack trace below.\n\n\n\n\n\n\n\n\nStack Trace: \n\n\n\n\n\n\n[InvalidOperationException: Both DataSource and DataSourceID are defined on 'RadMenu1'. Remove one definition.]\nSystem.Web.UI.WebControls.DataBoundControl.ConnectToDataSourceView() +3234866\nSystem.Web.UI.WebControls.DataBoundControl.OnLoad(EventArgs e) +28\nSystem.Web.UI.Control.LoadRecursive() +71\nSystem.Web.UI.Control.LoadRecursive() +190\nSystem.Web.UI.Control.LoadRecursive() +190\nSystem.Web.UI.Control.AddedControl(Control control, Int32 index) +11422584\nSystem.Web.UI.Control.EnsureChildControls() +182\nSystem.Web.UI.Control.PreRenderRecursiveInternal() +60\nSystem.Web.UI.Control.PreRenderRecursiveInternal() +222\nSystem.Web.UI.Control.PreRenderRecursiveInternal() +222\nSystem.Web.UI.Control.PreRenderRecursiveInternal() +222\nSystem.Web.UI.Control.PreRenderRecursiveInternal() +222\nSystem.Web.UI.Control.PreRenderRecursiveInternal() +222\nSystem.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4201\n\n\n\n\n\n\n\n\n\n\n\nVersion Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272\n<\/code><\/pre>\n<p>but I searched in my code as you can see above there&#8217;s only DataSourceID is defined.<\/p>\n<p>What should I do?<\/p>\n<p>Thanks<\/p>\n<ol>\n<li>\n<p>This value will be in the HTML of the .aspx page and not in the code behind. Check there, I have seen this issue before when migrating versions of Telerik RadControls.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-12-05 16:29:49. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>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: 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; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1948","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1948","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1948"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1948\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1948"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1948"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1948"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}