Follow us

Monday, March 21, 2011

Modify CSS List Menu Navigation Control in Kentico

Introduction

CSS List Menu is available as a Navigation webpart in Kentico.We can change CSS List Menu Items/HTML in few simple steps.

Stps

  1. You will need to access the RenderedHTML property of the CSS List menu web part.
    The this.menuElem.RenderedHTML property contains actual HTML generated by the control. You will need to parse it and add your code into appropriate place.
    This property can be modified by accessing code behind of CSS List Menu webpart.

    \CMSWebParts\Navigation\cmslistmenu.ascx.cs

  2. Modification can be done in OnPreRender(EventArgs e) event.
    By default,OnPreRender event is as follows:
     protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            this.Visible = this.menuElem.Visible;

            if (DataHelper.DataSourceIsEmpty(this.menuElem.DataSource) && (this.menuElem.HideControlForZeroRows))
            {
                this.Visible = false;
            }
        }
    After modification
    protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            this.Visible = this.menuElem.Visible;

            this.menuElem.RenderedHTML = this.menuElem.RenderedHTML.Replace("existingHTMLString", "newHTMLString");
            this.menuElem.LoadDataAutomaticaly = false;

            if (DataHelper.DataSourceIsEmpty(this.menuElem.DataSource) && (this.menuElem.HideControlForZeroRows))
            {
                this.Visible = false;
            }
        }
  3. After making changes to RenderedHTML, you need to set LoadDataAutomatically property to 'false'.

    this.menuElem.LoadDataAutomaticaly = false;

Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

1 comments: on "Modify CSS List Menu Navigation Control in Kentico"

varun said...

Thanks a lot for sharing the post on Kentico....

Really a nice and good detailed explanation..

Ray Business Technologies, www.raybiztech.com, is a leading IT Services Provider for Kentico CMS implementations. Raybiztech the Gold Kentico Partner,is the first Kentico partner to have 10 Certified Developers and is very experienced in Kentico Custom Design Templates and integration, Kentico Custom Modules Development and integration, Kentico Custom Components Development and integration and Kentico websites Maintenance.
Kentico CMS.

Post a Comment