Open RadContextMenu through Code

3 posts, 1 answers
  1. Richard Koslik
    Richard Koslik avatar
    71 posts
    Member since:
    Apr 2010

    Posted 16 Dec 2011 Link to this post

    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. Answer
    Yana
    Admin
    Yana avatar
    4554 posts

    Posted 16 Dec 2011 Link to this post

    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 >>

  3. DevCraft banner
  4. Richard Koslik
    Richard Koslik avatar
    71 posts
    Member since:
    Apr 2010

    Posted 19 Dec 2011 Link to this post

    Thanks, it works now!

    regards Richard Koslik
Back to Top