Tree view node selection from content page not updating master page control

6 posts, 0 answers
  1. Sabitri
    Sabitri avatar
    3 posts
    Member since:
    Feb 2014

    Posted 13 Mar 2014 Link to this post

    Hi Team,

    I am having a radtreeview in content page and a label in master page.
    On selection of tree node in content page I want to update the label text. 

    Below is the sample code I am using, but some how the update is not happening.

    content page aspx is having: rad tree with RadAjaxManagerProxy.
    <telerik:RadTreeView ID="xyz" runat="server" OnClientContextMenuItemClicked="xyz"
                            OnClientContextMenuShowing="xyz" OnClientDoubleClick="xyz"
                            OnClientNodeClicked="xyz" OnClientLoad="AddInfoToMenu" Height="440px">
                            <ContextMenus>
                                <telerik:RadTreeViewContextMenu ID="xyz" runat="server">
                                </telerik:RadTreeViewContextMenu>
                            </ContextMenus>
                        </telerik:RadTreeView>

    content page cs contains:
     RadAjaxManager manager = RadAjaxManager.GetCurrent(Page);
            manager.ClientEvents.OnRequestStart = "RequestInitiated";
            manager.ClientEvents.OnResponseEnd = "RequestEnded";
            manager.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(manager_AjaxRequest);

    master page update is happening if I am using a button click. but the node click of handled through ajax request is not updating label control.


    Any help appreciated.

    thanks
    Sabitri
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 13 Mar 2014 in reply to Sabitri Link to this post

    Hi Sabitri,

    Please have a look into the sample code snippet which works fine at my end.

    Master Page ASPX:
    <asp:Label ID="Label1" runat="server">
    </asp:Label>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    </telerik:RadAjaxManager>

    Content Page ASPX:
    <telerik:RadTreeView ID="RadTreeView1" runat="server" OnNodeClick="RadTreeView1_NodeClick">
        <Nodes>
            <telerik:RadTreeNode Text="Node1">
                <Nodes>
                    <telerik:RadTreeNode Text="Node1.1">
                    </telerik:RadTreeNode>
                    <telerik:RadTreeNode Text="Node1.2">
                    </telerik:RadTreeNode>
                </Nodes>
            </telerik:RadTreeNode>
        </Nodes>
    </telerik:RadTreeView>
    <telerik:RadAjaxManagerProxy ID="RadAjaxMangerProxy1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadTreeView1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="Label1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>

    Content Page C#:
    protected void RadTreeView1_NodeClick(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e)
    {
        Label label1 = (Label)this.Master.FindControl("Label1");
        label1.Text = e.Node.Text;
    }

    Let me know if you have any concern.
    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sabitri
    Sabitri avatar
    3 posts
    Member since:
    Feb 2014

    Posted 18 Mar 2014 in reply to Shinu Link to this post

    Thanks for the reply.

    I am using OnClientContextMenuItemClicked as the event to trigger a set of updates in db. OnClientContextMenuItemClicked is using ajax call and through manager_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e) updating the db. Can we somehow put the label text update after the changes in manager_AjaxRequest call. I tried to update label after that..but it is not working.

    any pointer..what I am missing there.
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 19 Mar 2014 in reply to Sabitri Link to this post

    Hi Sabitri,

    Please do the following modifications in the above posted code which works fine at my end.

    Master Page ASPX:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
    </telerik:RadAjaxManager>

    Master Page C#:
    protected void RadAjaxManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
    {
        //your code
    }

    JavaScript:
    <script type="text/javascript">
        function OnClientContextMenuItemClicked(sender, args) {
            var ajax = $find("<%=RadAjaxManager1.ClientID %>").ajaxRequest();
            var label = document.getElementById("Label1");
            label.textContent = args.get_node().get_text();
        }
    </script>

    Thanks,
    Shinu.
  6. Sabitri
    Sabitri avatar
    3 posts
    Member since:
    Feb 2014

    Posted 19 Mar 2014 in reply to Shinu Link to this post

    Thanks Shinu.

    Little confusion here I think, the Label1 is in master page and ajax request is triggered through content page.
    So Label1 is not be accessible in document.getelementbyid from OnClientContextMenuItemClicked(sender, args) of content page aspx.

    I am able to get master page Label1 control from contect page ajax function, but it is not reflecting in masterpage unless I do a refresh.
    But it is updating the Label1 text if I am updating it in a button click control from content page.

    protected void manager_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
    {
    var lbltest= (System.Web.UI.WebControls.Literal)Master.FindControl("Label1");
                        lbtest.Text = "test1";
    }

    Thanks
    Sabitri Mohanty
  7. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Mar 2014 in reply to Sabitri Link to this post

    Hi Sabitri,

    Please have a look into this sample project which works fine at my end. Let me know if you have any concern.

    Thanks,
    Shinu.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017