More in this section

Forums / Bugs & Issues / SiteMenu Wrapper control becoming null

SiteMenu Wrapper control becoming null

4 posts, 0 answered
  1. Michael
    Michael avatar
    4 posts
    Registered:
    15 Feb 2012
    15 Feb 2012
    Link to this post

    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; }

            }

     

     

  2. Jen Peleva
    Jen Peleva avatar
    568 posts
    Registered:
    10 Nov 2016
    20 Feb 2012
    Link to this post
    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
  3. Michael
    Michael avatar
    4 posts
    Registered:
    15 Feb 2012
    20 Feb 2012
    Link to this post
    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
        }
    }
  4. Jen Peleva
    Jen Peleva avatar
    568 posts
    Registered:
    10 Nov 2016
    24 Feb 2012
    Link to this post
    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
4 posts, 0 answered