Acessing control in Page_Load of normal user control results in Object not found
I'm trying to implement a menu where I can dynamically add a form to one of the menus as apposed to the regular sub menus. The rest of the menus will have sub menus.
The following is the Ascx code:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MajorMenu.ascx.cs" Inherits="Bounce.Web.Widgets.Navigation.MajorMenu" %><%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %><asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false" /><telerik:RadMenu OnItemDataBound="MajorRadMenu_ItemDataBound" ID="MajorRadMenu" runat="server" DataSourceID="SitemapDataSource1" MaxDataBindDepth="1" OnItemClick="MajorRadMenu_ItemClick"></telerik:RadMenu>using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace Bounce.Web.Widgets.Navigation public partial class MajorMenu : System.Web.UI.UserControl protected void Page_Load(object sender, EventArgs e) MajorRadMenu.ItemDataBound += new Telerik.Web.UI.RadMenuEventHandler(MajorRadMenu_ItemDataBound); void MajorRadMenu_ItemDataBound(object sender, Telerik.Web.UI.RadMenuEventArgs e) Response.Write("Hello"); Hello,
I have placed the code on a user control locally and I did not receive the Object reference.. error. However it is advisable to use the SitefinitySitemapDataSource instead for data source of the RadMenu. Additionally when binding RadMenu to a SitemapDataSource the server side ItemClicked event will not fire - take a look at the following article for more information. Try out the markup below:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TestControl.ascx.cs" Inherits="SitefinityWebApp.TestControl" %><%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %><%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.NavigationControls" TagPrefix="sf" %> <sf:SitefinitySiteMapDataSource ID="SitefinitySiteMapDataSource1" runat="server" ShowStartingNode="false" /><%--<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false" />--%><telerik:RadMenu ID="MajorRadMenu" runat="server" DataSourceID="SitefinitySiteMapDataSource1" MaxDataBindDepth="1" ></telerik:RadMenu>protected void Page_Load(object sender, EventArgs e) MajorRadMenu.ItemDataBound += MajorRadMenu_ItemDataBound; void MajorRadMenu_ItemDataBound(object sender, Telerik.Web.UI.RadMenuEventArgs e) Response.Write("Hello"); please something for this we very hurrid