Custom navigation template disappears on postback

Posted by Community Admin on 04-Aug-2018 20:02

Custom navigation template disappears on postback

All Replies

Posted by Community Admin on 05-May-2011 00:00

I have found an issue where the navigation control does not display when I set the custom template for the NavigationControl and a post back occurs. I am using the standard NavigationControl with the type set to horizontal with drop down. I then set the Custom template path for the control. I am using the following code for my template:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="menu.ascx.cs" Inherits="" %>
<telerik:RadMenu ID="radMenu" runat="server" EnableEmbeddedSkins="false">

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Sitefinity.Web;
using Telerik.Sitefinity.Web.UI;
using Telerik.Web.UI;
namespace SitefinityWebApp.Sitefinity.ControlTemplates.Navigation
    public partial class menu : System.Web.UI.UserControl
        protected override void CreateChildControls()
            if (this.BindingContainer.BindingContainer is Telerik.Sitefinity.Web.UI.NavigationControls.NavigationControl)
                Telerik.Sitefinity.Web.UI.NavigationControls.NavigationControl navControl = (Telerik.Sitefinity.Web.UI.NavigationControls.NavigationControl)this.BindingContainer.BindingContainer;
                if (navControl != null)
                    this.radMenu.MaxDataBindDepth = navControl.MaxDataBindDepth;
        protected void radMenu_ItemDataBound(object sender, RadMenuEventArgs e)
            if (e.Item.Level > 0)
                e.Item.Text = e.Item.Text.ToUpper();
        protected void Page_Load(object sender, EventArgs e)
        protected override void OnPreRender(EventArgs e)
            SiteMapNode node = SiteMapBase.GetCurrentNode();
            if (node != null)
                RadMenuItem item = this.radMenu.FindItemByUrl(this.ResolveUrl(node.Url));
                if (item != null)
                    item.Selected = true;
                    while (!(item.Parent is RadMenu))
                        item = (RadMenuItem)item.Parent;

When I use the built-in form control and submit the form, the page will reload but the navigation does not. If I remove the custom template, then the menu will show when the post occurs. Am I missing something in my template that is causing this, or is this something with the NavigationControl?

Posted by Community Admin on 11-May-2011 00:00

Hi Richard Baugh,

I am not sure that the CreateChildControls override will execute. This method is introduced in our classes and is not part of the UserControl class from .NET. Instead you should override the OnInit event of your user control. Then you should cast this.Parent to NavigationControl as the user control class is being held by the Container poperty of the navigation control.

Kind regards,
Radoslav Georgiev
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