Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
504
Nodeclick Client side event is not fired
posted

Hi,

I have a web application where i am using a LoadonDemand tree. My Scenario is to show the data on the right side WebTab. Now as the LoadOnDemand is on , hence what i read is that i cannot use the Server side Node clicked.

My Requirement is to click on a node and get the data back for this node from server. Since i am no longer able to use the Server side NodeClick, so to achieve this, i am using a hidden field inside the NodeClick client side event and getting the datakey of the clicked node and sending this hidden field value to the onserver change event of the hidden field. This hidden field is inside the update panel. and inside the onserverchange event i am getting th data for the clicked node.

 

Now when i click on the node, the node click does fire, which i check through the alert(nodeId), but the onserverchange for the hidden field does not get fire, instead it does get fire when i expand the node. This is very wierd behaviour right now.

 

Can any one help on this.

Following is the Nodeclick Client side function

=====================================

    function ubtDataTree_NodeClick(treeId, nodeId, button)
    {
          var node = igtree_getNodeById(nodeId);
      
          //Get the Hidden Control's Reference
          var hdnNode = document.getElementById("<%=hdnSelectedNode.ClientID%>");
          //Store the DataKey here in the Hidden Field, which makes the value change and onserverchange shoudl fire
          hdnNode.value = node.getDataKey();
         
          //alert(hdnNode.value);         
    }

 

Following is the Update panel and Hidden field

=======================================

<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true">
           
            <ContentTemplate>
            <input type="hidden" id="hdnSelectedNode" runat="server" onserverchange="HiddenServerChange"/>

......

 

following is the Onserverchange event i.e HiddenServerChange

================================================

protected void HiddenServerChange(object sender,System.EventArgs e)
    {
        if (myRandDS == null)
            myRandDS = new MyRandomDataSource();

        IDictionary attributes = myRandDS.GetNodeAttributes(hdnSelectedNode.Value);

        repAttributes.DataSource = attributes;
        repAttributes.DataBind();
     
    }

ANd Followin the repeater control ItemDataBound

========================================

    protected void repAttributes_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        Label lblKey = e.Item.FindControl("lblKey") as Label;
        Label lblValue = e.Item.FindControl("lblVal") as Label;
       
        if (lblKey != null && lblValue != null)
        {
           DictionaryEntry keyVal =(DictionaryEntry)e.Item.DataItem;
           lblKey.Text = Convert.ToString(keyVal.Key);
           lblValue.Text = Convert.ToString(keyVal.Value);
        }
    }

 

I get the right data but on wrong event, even though everything is in Node Click.

 

Am i missing something