SiteMenu Wrapper control becoming null

Posted by Community Admin on 04-Aug-2018 21:54

SiteMenu Wrapper control becoming null

All Replies

Posted by Community Admin on 15-Feb-2012 00:00

I have created a wrapper around the new SiteMenu to add a header and expose some of the properties in the Sitefinity admin.  However when you click Edit on the new control in Siteinfity the SiteMenu control becomes null.
 
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SiteMenuWithHeader.ascx.cs" Inherits="AkesocareWeb.UserControls.SiteMenuWithHeader" %>
<%@ Register TagPrefix="tk" Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.NavigationControls" %>
<div class="linkBox">
    <h4><asp:Label runat="server" ID="txtNavHeading"></asp:Label></h4>
    <tk:SiteMenu ID="SiteMenu1" runat="server" MaxDataBindDepth="1" ></tk:SiteMenu>
</div>
 
Then these throw null exception when clicking edit in the Sitefintiy admin backend.

        [Browsable(true)]
        [Category("Appearance")]
        public string CssClass
       
            get return this.SiteMenu1.CssClass;
            set this.SiteMenu1.CssClass = value;
       
 
 

Posted by Community Admin on 20-Feb-2012 00:00

Hello Michael,

We will need to take a look at the whole source of your control to determine where the problem comes from.

All the best,
Jen Peleva
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 20-Feb-2012 00:00

This is the full code-behind for the control.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using Telerik.Sitefinity;

namespace AkesocareWeb.UserControls
    /// <summary>
    /// Wrapper with header around the new SF4.4 SiteMenu control.
    /// </summary>
    public partial class SiteMenuWithHeader : System.Web.UI.UserControl
   

        #region Fields



        #endregion

        #region Properties

        [Browsable(true),
        Category("Form Fields"),
        Description("Allows the administrator to customize the properties of this label.")]
        public Label NavHeading 
       
            get return this.txtNavHeading;
            set this.txtNavHeading = value;
       

        /// <summary>
        /// Exposes the SiteMenu control with all properties.
        /// </summary>
        [Browsable(true)]
        public Telerik.Sitefinity.Web.UI.NavigationControls.SiteMenu NavigationMenu
       
            get return this.SiteMenu1;
            set this.SiteMenu1 = value;
       
        
        
        #endregion

        #region Events

        protected void Page_Load(object sender, EventArgs e)
       
            SetMenuHeading();
       


        #endregion

        #region Methods


        #region Private Methods

        /// <summary>
        /// If no heading is provided by the sitefinity administrator
        /// grab the Menu label for the current page to display
        /// as the heading for this control.
        /// </summary>
        private void SetMenuHeading() 
       
            if (string.IsNullOrEmpty(this.txtNavHeading.Text)) 
           
                var currentNode = Telerik.Sitefinity.Web.SiteMapBase.GetActualCurrentNode();
                if (currentNode != null)
               
                    txtNavHeading.Text = currentNode.Title;
               
           
       

        #endregion


        #region Public Methods


        #endregion


        #endregion
   

Posted by Community Admin on 24-Feb-2012 00:00

Hello Michael,

I believe you forgot to create a field in your control for CssClass. Take a look at the sample below:

#region Fields
 private string cssClass;


Regards,
Jen Peleva
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed