MenuControl issue

harshal bundelkhandi asked on July 23, 2014 13:53

Hi Team,

I am facing in extending properties of CMSAbstractMenuProperties abstract class. In Content tab i have select path as /Home/Products/% but when i call getDataSource method it bind from root and when i check path string variable it show /% so it not reflecting my changes. if i use CMSAbstractWebPart abstract class then path is correct. can u suggest me why this happening?

Recent Answers


Brenden Kehren answered on July 23, 2014 16:01 (last edited on July 23, 2014 16:01)

First off, we might step back and ask what you are trying to accomplish vs. jump in the middle of possibly recreating something that already exists.

0 votesVote for this answer Mark as a Correct answer

harshal bundelkhandi answered on July 23, 2014 16:31

Yes I am extending the layout of menu control as per as requirement. please see below code i have add comment in bold.

protected override void OnLoad(EventArgs e) { if (!string.IsNullOrEmpty(this.HoverCSSClassName) && BrowserHelper.IsIE() && this.Page.Header.FindControl("GCProductMenuStyleHeaderControl") == null) { string arg = CMS.Base.SystemContext.ApplicationPath.TrimEnd(new char[] { '/' }); string style = string.Format(".{0} LI {{ BEHAVIOR: url({1}/CMSScripts/LIhover.htc) }}", this.HoverCSSClassName, arg); string style2 = CSSHelper.GetStyle(style); Control control = new LiteralControl(style2); control.ID = "GCProductMenuStyleHeaderControl"; this.Page.Header.Controls.Add(control); } base.OnLoad(e); } /// /// Indicate if data will be loaded whatever datasource is not empty ///

    public override void ReloadData(bool forceLoad)
    {

        this.SetContext();
        this.mRenderedHTML = "";
        if (this.StopProcessing || this.Context == null)
        {
            return;
        }
        string text = ",";
        this.EnableViewState = false;
        if (this.DataSource == null || forceLoad)
        {
            if (this.FilterControl != null)
            {
                this.FilterControl.InitDataProperties(this);
            }
            **this.DataSource = base.GetDataSource(false);**

//above line bind element from root element not define path by me } if (DataHelper.DataSourceIsEmpty(this.DataSource)) { return; } if (!string.IsNullOrEmpty(this.HoverCSSClassName)) { this.mRenderedHTML = this.mRenderedHTML + "<div class=\"" + this.HoverCSSClassName + "\">"; } int integer = ValidationHelper.GetInteger(this.DataSource.Tables[0].Rows[0]["NodeLevel"], 0); foreach (DataRowView dataRowView in this.DataSource.Tables[0].DefaultView) { if (ValidationHelper.GetInteger(dataRowView["NodeLevel"], 0) != integer) { break; } if (text.IndexOf("," + Convert.ToInt32(dataRowView["NodeParentID"]).ToString() + ",", 0) < 0) { this.DataSource = base.GetDataSource(true); string ss = this.Path;

                this.mRenderedHTML += this.GetItems(ValidationHelper.GetInteger(dataRowView["NodeParentID"], 0), 0);

                **//when above method call it return nodeparentID is 2 which is wrong** 

                //this.mRenderedHTML += this.GetItems(15, 0);

                text = text + ValidationHelper.GetString(dataRowView["NodeParentID"], string.Empty) + ",";
            }
        }
        if (!string.IsNullOrEmpty(this.HoverCSSClassName))
        {
            this.mRenderedHTML += "</div>";
        }
        this.ReleaseContext();
    }
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.