Click Contextmenu block (or Instead) the event

2 posts, 0 answers
  1. Hon
    Hon avatar
    1 posts
    Member since:
    Jul 2010

    Posted 31 Jul 2013 Link to this post

    Dear  experts , how  to handle  following

      after  click  on  the  Context menu  item  in  onClientContextMenuItemClicking (or OnClientContextMenuItemClicked)  event,  and  then  the  popup  div  layers (or aspx pages), and  gets  inside  the  text  of  TextBox1(TextBox1.Text:


    1. when TextBox1.text  is  not  null (or is  not  empty  string ), return  true, and  execut  service RadTreeView1_ContextMenuItemClick  event  ;

    2. when TextBox1.text is null (or empty string), returns  false, will  does not  execut  services RadTreeView1_ContextMenuItemClick  event.



    Client  code:

    function onClientContextMenuItemClicking(sender, args) {

    var menuItem = args.get_menuItem();

    var treeNode = args.get_node();


    switch (menuItem.get_value()) {

    case "new":

    var  result=  pseudocode(pop-up layer :  when  input  text  of  TextBox1 is not null or not  empty  string ): return true;  when TextBox1.text  is null  or empty  string  return  false.);





    1.  /*  When variable  result  return  false  and  did not  execut RadTreeView1_ContextMenuItemClick .   Key points: When the pop-up layers, how to block  the  program to continue execut */  

    2. /* this (pseudocode) is  my problem , and  how can  I  write  the  code ? */


    Services  code:


    protected void RadTreeView1_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)


    RadTreeNode clickedNode = e.Node;

    switch (e.MenuItem.Value)


    case "new":

    if(! IsNullOrEmpty (textbox1.text))



    many  thanks!

  2. Hristo Valyavicharski
    Hristo Valyavicharski avatar
    975 posts

    Posted 05 Aug 2013 Link to this post

    Hi Hon,

    Execution will stops and RadTreeView1_ContextMenuItemClick event will not fired if you cancel the client onClientContextMenuItemClicking event. Just be sure that pass true as argument: args.set_cancel(true);

    For the the second issue you may try to replace your pseudo code with the following:
    function onClientContextMenuItemClicking(sender, args) {
        var menuItem = args.get_menuItem();
        var treeNode = args.get_node();
        //Get text value of TextBox1
        var text = $get('TextBox1').value;
        switch (menuItem.get_value()) {
            case "new":
                //Check if TextBox1 contains any text
                var result = isEmpty(text);
                //If TextBox1 is empty cancel the event and stops execution
    function isEmpty(value) {
        return (typeof value === "undefined" || value === null || value === "");

    Hristo Valyavicharski
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. DevCraft R3 2016 release webinar banner
Back to Top