Context Menu ItemClick serverSideEvent

9 posts, 0 answers
  1. Chris O
    Chris O avatar
    56 posts
    Member since:
    May 2006

    Posted 29 May 2008 Link to this post

    if i have a list of elements that display the menu when selected.  When a menu item is selected on the client it fires the server event  OnItemClick="ContextMenuSelected" 


    <a ondblclick="showMenu(event)">102.</a>


    void ContextMenuSelected(object sender, RadMenuEventArgs e)



    RadMenuItem ItemClicked = e.Item;
    System.Diagnostics.Debug.WriteLine("Server event raised -- you clicked: " + ItemClicked.Text);

    How can I tell which page element the item was selected from.  i want to know that it was 102. that the menu was called from


  2. Atanas Korchev
    Atanas Korchev avatar
    8462 posts

    Posted 30 May 2008 Link to this post

    Hello Chris Olsen,

    RadMenu does not provide built-in support for that. However you can store the ID, or value of the clicked element in some hidden field and access it on the server side. Here is a quick example:

    <input type="hidden" id="currentElement" />
    <a ondblclick="showMenu(this, event)">102</a>

    <script type="text/javascript">

    function showMenu(element, e)
        var currentElement = $get("<%= currentElement.ClientID %>");
        currentElement.value = element.innerHTML;

        //Show the context menu here

    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Chris O
    Chris O avatar
    56 posts
    Member since:
    May 2006

    Posted 30 May 2008 Link to this post


    This did work with a modification.  I was unable to use
    currentElement.value = element.innerHTML;
    instead I had to use

    currentElement.value = element.srcElement.childNodes[0].nodeValue;

    Thanks for the idea.
  4. John Fetherolf
    John Fetherolf avatar
    30 posts
    Member since:
    Sep 2006

    Posted 11 Sep 2008 Link to this post

    Just got around to needing RadContextMenu today and had to read through 11 pages of posts to find this answer :(

    Anyway the ultimate question is:  If you allow a collection of targets (controls) on the server side, why on earth would the server event not need to know what the target control that caused the event was?  Is this going to be passed to the server in a future version of the controls?  This seems kind of silly to me that you can't determine the actual target of the context menu from the server-side events.

  5. Chad
    Chad avatar
    19 posts
    Member since:
    Aug 2008

    Posted 19 Sep 2008 Link to this post

    So is there no way to access the item that triggered the event without using javascript?

    I'm trying to implement the context menu into a RadScheduler that is being used in MOSS as a webpart. I can get the menu to open but I can't tell it to show different options depending on the item the context menu was activated from.

    If it's an appointment, show something.
    If its a timeslot, show something different.
    If it's neither, do nothing at all.

    An example menu item would be "Change Color Red"... when clicked it would get the ID of the appointment and update that appointment's color field value on the MOSS list that the scheduler is tied to.

    Server side access is a no go? =(
    I hate javascript...
  6. Marcel
    Marcel avatar
    1 posts
    Member since:
    Nov 2008

    Posted 25 Mar 2010 Link to this post

    Storing the ID into a hidden field and posting it back to the server is an extremely disappointing answer, I must say. If RadContextMenu has a Targets collection and an OnItemClick server event, I at least expect to be able to access the target whose context menu was clicked.

    Will this be fixed in a future release?
  7. Veselin Vasilev
    Veselin Vasilev avatar
    2992 posts

    Posted 30 Mar 2010 Link to this post

    Hello Marcel,

    We will consider implementing a property in the event arguments which will contain the ID of the html element that was clicked.

    All the best,
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  8. Mark
    Mark avatar
    5 posts
    Member since:
    Oct 2010

    Posted 10 Feb 2011 Link to this post

    Did this get resolved?

    I also have an issue.  I have a org chart that i have as a seperate project.

    Im using

    protected void SetContext()
        //    // Add file view context menu  
        int i = 0;
        while (i < Org1.ChartItems.Count)
            ContextMenuControlTarget target = new ContextMenuControlTarget();
            string tg = Org1.ChartItems[i].ItemId.ToString();
            target.ControlID = "I" + tg;       

    to add the radcontextmenu on each control (they are divs).

    However when i try to find out what targetitem called the contextmenu, it returns "undefined".

    Am I doing something wrong?

    <script type="text/javascript">
        function onClicking(sender, eventArgs) 
            var item = eventArgs.get_item();
            var navigateUrl = item.get_navigateUrl();
            var targetitem = eventArgs.get_targetElement().value;
      /*      if (navigateUrl && navigateUrl != "#") 
                var proceed = confirm("Navigate to " + navigateUrl + " ?");
                if (!proceed) {
                else {
  9. Yana
    Yana avatar
    5002 posts

    Posted 15 Feb 2011 Link to this post

    Hello Mark,

    Could you please open a support ticket and send us a runnable page demonstrating the issue? Thanks

    Kind regards,
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top