This is a migrated thread and some comments may be shown as answers.
Dynamically load context menu with server side code
2 Answers 25 Views
This is a migrated thread and some comments may be shown as answers.
Donald Norris
Top achievements
Rank 1
Donald Norris asked on 17 Jul 2011, 11:23 PM
Could you please show some examples of creating a context menu from server side code?

Thanks

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 18 Jul 2011, 06:34 AM
Hello Donald,

Try the following code snippet to add ContextMenu dynamically. Hope this helps.

C#:
protected void Page_Load(object sender, EventArgs e)
{
        if (!IsPostBack)
        {
            RadTreeViewContextMenu contextMenu1 = new RadTreeViewContextMenu();
            contextMenu1.ID = "contextMenu1";
            RadMenuItem menuItem1 = new RadMenuItem();
            menuItem1.Text = "item1";
            contextMenu1.Items.Add(menuItem1);
            RadMenuItem menuItem2 = new RadMenuItem();
            menuItem2.Text = "item2";
            contextMenu1.Items.Add(menuItem2);
            RadTreeView1.ContextMenus.Add(contextMenu1);
        }
}

Thanks,
Princy.
0
Kate
Telerik team
answered on 20 Jul 2011, 01:09 PM
Hi Donald,

You could also refer to the full help article here.

All the best,
Kate
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Menu
Asked by
Donald Norris
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Kate
Telerik team
Share this question
or