This is a migrated thread and some comments may be shown as answers.

Open RadContextMenu through Code

2 Answers 137 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Richard Koslik
Top achievements
Rank 1
Richard Koslik asked on 16 Dec 2011, 12:53 PM
Hello,

I have a question about the RadContextMenu. My problem is I am not able to open a RadContextMenu manually through the code.

* I created a ContextMenu + MenuItems in code behind
* I NOT called the function RadContextMenu.SetContextMenu
* I set IsOpen = true for opening the menu => Error:  Unhandled Error (Application_UnhadledException) Object reference not set to an instance of an object

What do I wrong, how can I open a ContextMenu through code behind????

regards Richard Koslik

2 Answers, 1 is accepted

Sort by
0
Accepted
Yana
Telerik team
answered on 16 Dec 2011, 02:45 PM
Hi Richard,

You should set a target to the context menu in order to open it properly. This can be done by other using SetContextMenu method as explained here or setting its PlacementTarget property:

RadContextMenu contextMenu = new RadContextMenu();
contextMenu.Items.Add(new RadMenuItem() { Header = "test item" });
contextMenu.PlacementTarget = targetTextbox;
contextMenu.IsOpen = true;

Kind regards,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Richard Koslik
Top achievements
Rank 1
answered on 19 Dec 2011, 09:09 AM
Thanks, it works now!

regards Richard Koslik
Tags
Menu
Asked by
Richard Koslik
Top achievements
Rank 1
Answers by
Yana
Telerik team
Richard Koslik
Top achievements
Rank 1
Share this question
or