Treeview context menu click client and server side code both getting executed simultaneously

3 posts, 0 answers
  1. Manas
    Manas avatar
    5 posts
    Member since:
    Apr 2012

    Posted 07 May 2012 Link to this post

    Hi I have a RadTreeView where I have implemented a context menu on the nodes.

    <telerik:RadTreeView ID="RadTreeView1" runat="server" OnContextMenuItemClick="RadTreeView1_ContextMenuItemClick" OnClientContextMenuItemClicking="onClientContextMenuItemClicking">               
                        <telerik:RadTreeViewContextMenu ID="ctxMenuAddK1" runat="server">
                                <telerik:RadMenuItem Value="addNodeK1" Text="Add New K1 Node">

    when user clicks the menu item, the client side event fires and a modal popup is displayed to the user. the modal popup has 2 text boxes, when user enters value in those text boxes and submits the popup, the text box values are concatenated and sent back to the calling page, where this value id captured in a hidden field.

    case "addNodeK1":
    var windowResult = window.showModalDialog("Controls\\newNodeK1.htm", "Enter Value", "dialogHeight: 300px; dialogWidth: 400px;");
    document.getElementById('<%=HiddenField1.ClientID %>').value = windowResult;

    now the control goes to the server side context menu click event. here I am picking up the value from the hidden field, and do my tasks.

    protected void RadTreeView1_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
    switch (e.MenuItem.Value)
    case "addNodeK1": 
    // get node name and node value from the hidden field.
    string nameValue = HiddenField1.Value;

    This works fine. the modal popup holds the execution until a value is submitted by the user. but the issue comes when I try to use radWindow instead of the modal popup.

    I have added a radWindowManager and one child radWindow inside it. 

    <telerik:RadWindowManager ID="RadWindowManager1" ShowContentDuringLoad="false" VisibleStatusbar="false"
            ReloadOnShow="true" runat="server" Skin="Sunset" EnableShadow="true">
                <telerik:RadWindow ID="RadWindow1" runat="server" Behaviors="Close" OnClientClose="OnClientClose"

    and I am trying to invoke the radwindow in the context menu clicked on the client.

    var oWnd = radopen("Controls\\newNodeK1.htm", "RadWindow1");

    The problem is that unlike the modal popup, it does not hold the execution. the RadWindow appears but the server side code executes simultaneously, and since the hidden field ie empty, my code does not work. what could be the solution of this problem? 
  2. Marin Bratanov
    Marin Bratanov avatar
    3562 posts

    Posted 09 May 2012 Link to this post

    Hi Manas,

    The RadWindow is pure JavaScript and thus it cannot block the execution thread like the built-in browser dialogs can. The way to handle this is to use JavaScript and return the values from the RadWindow in its OnClientClose event as shown in this demo and this help article. This is the place where you would need to initiate a postback or ajax request (e.g. the ajaxRequestWithTarget() method of the RadAjaxManager) to  get the values to the server and perform your logic. You could use another hidden field to store the menu item that was clicked and prevent the default postback of the menu when the certain item (add K1 node) is clicked (via the set_cancel() method of the event arguments object the OnClientContextMenuItemClicking provides).  


    Kind regards,
    the Telerik team
    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 their blog feed now.
  3. DevCraft R3 2016 release webinar banner
  4. Manu
    Manu avatar
    23 posts
    Member since:
    Aug 2015

    Posted 22 Dec 2015 in reply to Marin Bratanov Link to this post



    Please help me out from my problem, it may be small but i cant make it out.

    I am using a RadTreeView. its working fine but my requirment is i want to add some condition in between nodes of treeview. so that i have to display nodes based on that if condition.

     Thanks in advance. :)

Back to Top