ContextMenu and ajaxRequestWithTarget

2 posts, 1 answers
  1. Henrique Duarte
    Henrique Duarte avatar
    106 posts
    Member since:
    Oct 2003

    Posted 08 Jun 2008 Link to this post

    I'm using a context menu to call an async callback using ajaxManager ...

        <telerik:RadContextMenu ID="contextMenu" runat="server" Skin="Hay" OnClientItemClicked="ItemClicked" Style="top: 164px; left: 11px"
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
            <Items> 
                <telerik:RadMenuItem Text="Igual" Value="Igual" PostBack="False"
                </telerik:RadMenuItem> 
                <telerik:RadMenuItem Text="Contém" Value="Contém" PostBack="False"
                </telerik:RadMenuItem> 
            </Items> 
        </telerik:RadContextMenu> 
     

        <script type="text/javascript"
        function ItemClicked(sender, args) 
        { 
        $find("ajaxManager").ajaxRequestWithTarget("bFiltro", ""); 
        } 
        </script> 

    ... but the clicked item is keeping selected. Removing the ajaxRequest, everything works as expected.
    How can I cancel the selected the item on context menu?

    []'s,

    Henrique
  2. Answer
    Helen
    Admin
    Helen avatar
    1052 posts

    Posted 10 Jun 2008 Link to this post

    Hello Henrique,

    You have to add an ajax setting button to update the context menu. Please refer to the code below:
    aspx:
    <asp:ScriptManager ID="ScriptManager1" runat="server">  
          </asp:ScriptManager> 
          <script type="text/javascript">    
            function ItemClicked(sender, args)    
            {    
                  
                $find("ajaxManager").ajaxRequestWithTarget("Button1", "");    
            }    
        </script>    
     
            <telerik:RadContextMenu ID="contextMenu" runat="server" Skin="Hay" OnClientItemClicked="ItemClicked" Style="top: 164px; left: 11px; z-index: 100;">    
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>    
            <Items>    
                <telerik:RadMenuItem Text="Igual" Value="Igual" PostBack="False">    
                </telerik:RadMenuItem>    
                <telerik:RadMenuItem Text="Contém" Value="Contém" PostBack="False">    
                </telerik:RadMenuItem>    
            </Items> 
            <Targets> 
                <telerik:ContextMenuDocumentTarget /> 
            </Targets>    
        </telerik:RadContextMenu>   
        <telerik:RadAjaxManager id="ajaxManager" runat="server">  
            <AjaxSettings> 
                  
                <telerik:AjaxSetting AjaxControlID="ajaxManager">  
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="contextMenu" /> 
                        <telerik:AjaxUpdatedControl ControlID="Label1" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
                <telerik:AjaxSetting AjaxControlID="Button1">  
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="contextMenu" /> 
                        <telerik:AjaxUpdatedControl ControlID="Label1" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
          
        </telerik:RadAjaxManager> 
            <asp:Label ID="Label1" runat="server" Style="z-index: 101; left: 360px; position: absolute;  
                top: 398px"></asp:Label> 
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Style="z-index: 103;  
                left: 223px; position: absolute; top: 396px" Text="Button" /> 

    cs:
    protected void Button1_Click(object sender, EventArgs e)  
        {  
            Label1.Text = "ButtonClicked";  
        } 

    Hope this helps.

    Regards,
    Helen
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top