I made a couple of changes and your example is working properly now. Here is the code
<%
@.PageLanguage="C#" %><%
@.RegisterAssembly="Microsoft.Web.Atlas"Namespace="Microsoft.Web.UI"TagPrefix="atlas" %><!
DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><
scriptrunat="server">protectedvoid Page_Load(object sender,EventArgs e){
}
protectedvoid btn_Click(object sender,EventArgs e){
txt1.Text =
DateTime.Now.ToString();}
protectedvoid tree_TreeNodePopulate(object sender,TreeNodeEventArgs e){
TreeNode node =newTreeNode(e.Node.Value +"x", e.Node.Value +"x");node.PopulateOnDemand =
true;node.SelectAction =
TreeNodeSelectAction.Expand;e.Node.ChildNodes.Add(node);
}
</
script><
htmlxmlns="http://www.w3.org/1999/xhtml"><
headrunat="server"><title>Untitled Page</title></
head><
body><formid="form1"runat="server"><atlas:ScriptManagerID="scriptmanager"EnablePartialRendering="true"runat="Server"/><divstyle="width: 400px; float: left"><atlas:UpdatePanelrunat="server"ID="up1"><ContentTemplate><asp:TreeViewrunat="server"ID="tree"ExpandDepth="1"EnableViewState="true"OnTreeNodePopulate="tree_TreeNodePopulate"><Nodes><asp:TreeNodeValue="1"Text="1"PopulateOnDemand="True"></asp:TreeNode><asp:TreeNodeValue="2"Text="2"PopulateOnDemand="True"></asp:TreeNode></Nodes></asp:TreeView></ContentTemplate></atlas:UpdatePanel></div><div><atlas:UpdatePanelrunat="server"ID="up2"><ContentTemplate><asp:TextBoxrunat="server"ID="txt1"></asp:TextBox><asp:Buttonrunat="server"ID="btn"Text="Button"OnClick="btn_Click"/></ContentTemplate></atlas:UpdatePanel></div><br/></form></
body></
html>Hope This helps!
Thanks, it did help me indirectly. My example aspx was somewhat simplified compared to my code, because I was also placing embracing TreeView with user control and creating TreeView dynamically in code-behind. It turned out that I had a line in my TreeViewUserControl.cs inside OnInit:
if (!Page.IsPostBack) buildTreeLevel(treeHierarchy, 0, 0, navigationTree.Nodes,ref ds, AllowAdding,"");
which I used to populate initial nodes. I thought it made sense to populate root of
the tree only in initial page requests and not on postbacks. When I commented out first if line,
it all works fine.
Thanks
No comments:
Post a Comment