Showing posts with label node. Show all posts
Showing posts with label node. Show all posts

Wednesday, March 28, 2012

Tree Control within Grid Control using AJAX and ASP.Net

Hi, I need a tree control inside a grid control, i.e.., every node of the tree should be a row in the grid control. I want to implemented this using AJAX. Please let me know how this has to be implemented.

Hi

every node of the tree should be a row in the grid control?

I'm afraid you cann't implement this,Html can be writed like this.

Best Regards

Tree Control within Grid Control using AJAX

Hi,
I need a tree control inside a grid control, i.e.., every node of the tree should be a row in the grid control.
I want to implemented this using AJAX. Please let me know how this has to be implemented.

Hi TinyTin,

I have found that you have posted the same thread on Asp.Net Ajax UI with this url: http://forums.asp.net/t/1141859.aspx. so we will mark it as "resolved", if you have any problems or new findings , please feel free to reply onhttp://forums.asp.net/t/1141859.aspx.

By the way, based on my experience, I'm afraid that we cannot achieve what you want by using any controls in Ajax Control Toolkit directly. Thanks.

Best Regards,

Jonathan

Tree view nested in Accordion taking two clicks to fire selectedNodeChanged event

I have a treeview in one of my accordion panes. When I click on a node for the first time, instead of firing the selectedNodeChanged event, it just goes through a normal postback. However the second time I click it, the event is fired correctly. Is there another event being fired that I'm not seeing?

Here's a trimed down version of the code. Thanks for any ideas. -d

<atlasToolKit:Accordion ID="navAccordion" runat="server" Height="410"
FadeTransitions="true" FramesPerSecond="40"
TransitionDuration="250"
AutoSize="None"
>

<atlasToolKit:AccordionPane ID="AccordionPane2" runat="server">
<Header><a href="http://links.10026.com/?link=" onclick="return false;" class="accordionLink">Tank Groups</a></Header>
<Content>
<asp:Panel ID="navPanel" runat="server" ScrollBars="auto" CssClass="extraPadding" BackColor="white" Width="180" Height="200">
<asp:TreeView ID="navTankGroups" OnUnload="nav_Unload" OnSelectedNodeChanged="nav_SelectedNodeChanged" runat="server" SkinID="nav" >
<Nodes>
<asp:TreeNode Text="Page 1" Value="~/page1.aspx" />
<asp:TreeNode Text="Page 2" Value="~/page2.aspx" />
</Nodes>
</asp:TreeView>
</asp:Panel>
</Content>
</atlasToolKit:AccordionPane>
</atlasToolKit:Accordion>

Here's the selectedNodeChanged routine.

Protected Sub nav_selecedNodeChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim navTankGroups As TreeView = CType(AccordionPane2.ContentContainer.FindControl("navTankGroups"), TreeView)
If Not navSchedule.SelectedNode.ValuePath = String.Empty Then
Response.Redirect(navTankGroups.SelectedNode.Value)
End If
End Sub


This appears to only be an issue on master pages. I placed the accordion in a new page and it worked fine. Anyone have an idea on why it is taking two clicks in the masterpages? -d

Hi dtamber,

I'm not sure what's going on with this... could you perhaps post the simplest possible version you have that still causes the problem?

Thanks,
Ted


Look at the source code before and after the button click, there is one of 2 possibilities.

1. someting being created dynamicly doesn't have an ID property set, in this case you'll see the treeview control in the source with different names

Like ctl03 and ctl05 in the treeview's name

2. I have fixed my postback issues by adding a hidden field to each accordion pane at page_init. I don't know why this fixes the erradic behavior, but it does.

Let me know if either of these works.

Chris


I think this needs a bump.

I just tried using an accordion in a usercontrol and added 3 panes, each containing an updatepanel containing a button.

The button click event is not fired. Adding a hidden field as Chris suggested allows the click event to fire.

Nathan


I also ran into the exact same problem. I was using a gridview inside an accordion and the events weren't firing the first attempt. If you add a control to it during OnInit then it appears to work. My assumption is that there's a problem with the RenderControls or something.

Astynax777:

I also ran into the exact same problem. I was using a gridview inside an accordion and the events weren't firing the first attempt. If you add a control to it during OnInit then it appears to work. My assumption is that there's a problem with the RenderControls or something.

Astynaxx777 - This clicking twice problem has been a real issue for me. Can you please elaborate with a small example if possible? You mean to add a control to the AccordionPane when the page loads (through the code behind)?

Your help would be greatly appreciated.


I ran into the same problem where I couldn't get a Button click event to fire off until I did whatCConchelos tried:

"2. I have fixed my postback issues by adding a hidden field to each accordion pane at page_init. I don't know why this fixes the erradic behavior, but it does."

Here's a basic example:

 
<body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <div> </div> <cc1:Accordion ID="Accordion1" runat="server"> <Panes> <cc1:AccordionPane ID="AccordionPane1" runat="server"> <Header>Test1</Header> <Content> <asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton> </Content> </cc1:AccordionPane> <cc1:AccordionPane ID="AccordionPane2" runat="server"> <Header>Test2</Header> <Content> <asp:Button ID="Button1" runat="server" Text="Button" /> </Content> </cc1:AccordionPane> </Panes> </cc1:Accordion> </form></body>

The Button1 click event would not get called until I added a hidden field to the AccordionPane that contained Button1 on the Page_Init:

Private Sub Page_Init(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles MyBase.InitDim myAccordionPaneAs AccordionPaneDim myTextBoxAs New TextBox myTextBox.Visible =False myAccordionPane =MyBase.FindControl("AccordionPane2") myAccordionPane.Controls.Add(myTextBox)End Sub

I thinkAstynax777 is right - there must be something wrong with the controls inside an AccordionPane when being rendered.


Thank you very much. It should be noted that after Astynax777's suggestion I tried it with a button and I forgot to hide it, and it didn't work as expected.

Excellent example, thanks again.


Hi,

has anyone found out more about this issue? As indicated in a previous post, the issue appears to be that controls are not rendered properly the first time the accordion is loaded. When the postback occurs, the controls have a different id, and no event is fired since it cannot be hooked up to the appropriate control (since the ID has changed).

I have a slightly different problem than those posted above as the accordion I'm working with is loaded via a datasource. I cannot add controls on the init event as a temporary fix. Any idea for a workaround would be greatly appreciated until this is resolved.

Thanks


btw, this "click twice" error disappears when I have only 1 accordion control on a page. If there are two accordion controls (one is data bound, the other is not), then I have to click twice. When I only have the databound accordion, it works as intended.

The good thing is that adding the "invisible" control to each pane in the Accordion which is not databound has fixed the "click twice" error in the databound Accordion.


Ok, I think I have this problem fixed. You can see the changes I made athttp://www.codeplex.com/AtlasControlToolkit/WorkItem/View.aspx?WorkItemId=5796 . There's 2 files I uploaded for that issue. I might help you... or it might not, I have not tested it for your problem but it certainly fixed mine! Good luck.


Has anybody else tried it with the new 10660 release? For me, the event handling never worked. My accordion is completely databound and does not contain any unbound panes. Consequently, the workaround will not work for me. I've just tried it with 10660, but no change.

Dennis Doomen
Aviva Solutions


I was having all of those 'click twice' problems but in randomly places. I used Accordions on many different pages and I couldnt figure out why it worked on some pages and didnt on others. I realized that on the page that it didnt work I was doing my control loading during OnInit and on my other pages that did work it was during PageLoad. Im guessing you have to make sure that everything must be done in one or the other. If you have User Controls make sure that your logic and things are also in it's page load as well. Dont mix and match :)

Treeview & UpdatePanel - Assertion failed - cant find last / in base url

Hi,

I am using a TreeView and couple of server controls. The treeview children are dynamically added on click of a node. I have the treeview control inside an update panel. Everything works if I access the page in a normal IE window. When I try to access the same page through a modal dialog, during postback, it opens a new window. To avoid that, I've added<base target = "_self" />.

Now I'm getting another error with Atlas. On click of tree node, it says "Assertion Failed : Can't find last / in base url. If I remove the <base..> it doesn't work.

Looking for an immediate solution. I've spent almost a day in googling. But no luck yet.

Many Thanks,
Mani.

hello.

you can also try using an iframe inside your popup page (ie, put only an iframe inside your popoup window which loads the page that shows the content)...maybe it'll solve that problem.


Mani,

Add:<basetarget="_self"href="http://localhost/***/***/"runat="server"/>

because our dear js function check if u have base tag , then try to concat with href value. in your case you don't have it.

T.


what if i'm using a Master Page - i can't hard code a path in the href. Is there any way to accomplish this? Plus - even if i hard code, the paging on my grid view does not work now.

trans642:

Mani,

Add:<basetarget="_self"href="http://localhost/***/***/"runat="server"/>

because our dear js function check if u have base tag , then try to concat with href value. in your case you don't have it.

T.

GOOD THANKS !


trans642:

Mani,

Add:<basetarget="_self"href="http://localhost/***/***/"runat="server"/>

because our dear js function check if u have base tag , then try to concat with href value. in your case you don't have it.

T.

GOOD THANKS !


Try this, without hard code urlSmile
 <base target="_self" href="<%=Request.Url.OriginalString%>" />

works perfect ... Thanks.

Treeview acting strange in UpdatePanel

We are having issues with a treeview in an updatepanel with the RC release. When we click a child node, sometimes it closes other nodes at the same level. When a closed node is expanded again, it has a child node that is expanded. It looks like the treeview is mixing up an opened node with one of its child nodes. If we take it out of an update panel, it works fine, but does full postbacks at every click. Any ideas how to fix this problem?

treeview is not supported by Ajax.NET (I heard rumours about Q3 Orcas -related update)

do search in the forum


I have been searching, but didn't find much. It is just yet another ASP.NET control that isn't supported with UpdatePanels since the CTPs...

I would say treeview made troubles even in CTPs...

this control is discussed quite often here, even the post preceding yours mentions that...

http://forums.asp.net/thread/1514853.aspx


It worked fine for us before, and the menu also did. We were also able to use ReportViewers without having to do a full postback, which you have had to since the Betas.

I am really disappointed that Menu and TreeView controls are not supported in ASP.Net AJAX UpdatePanels. I have a production website that successfully uses Menu and TreeView controls in UpdatePanels using the July CTP of Atlas. Sounds like I will never be able to upgrade to the fully supported ASP.Net AJAX version. I know that the TreeView control can do an asynchronous callback for the TreeNodePopulate event, but I also need partial page postbacks for the SelectedNodeChanged event. In fact, I want PopulateNodesFromClient to be false anyway otherwise the atlas UpdateProgress control does not appear for TreeNodePopulate event asynchronous callbacks. And I extensively use Menu controls to create tabstrips in combination with a MultiView control. I hope Menu and Treeview support can still be added to the final version of ASP.Net AJAX.

Remco

treeview expand depth 2 collapse to depth level 0.

I have treeview on update panel and loading folders based on user interaction. It works for depth level 2 but at this point clicking the node shows depth level 0 results. is there something I am missing?

here are few lines of crap...

Thanks for you help.

<asp:TreeViewid="SourceTreeView"runat="server"Width="100%"OnSelectedNodeChanged="SourceTreeView_SelectedNodeChanged"OnTreeNodeExpanded="SourceTreeView_TreeNodeExpanded"ShowCheckBoxes="Leaf"ImageSet="Simple"Height="100%"ExpandDepth="1"MaxDataBindDepth="10"NodeIndent="15">

<ParentNodeStyleFont-Bold="False"></ParentNodeStyle>

<HoverNodeStyleForeColor="#5555DD"Font-Underline="True"></HoverNodeStyle>

<SelectedNodeStyleHorizontalPadding="0px"ForeColor="#5555DD"VerticalPadding="0px"Font-Underline="True"></SelectedNodeStyle>

<NodeStyleNodeSpacing="0px"HorizontalPadding="0px"ForeColor="Black"VerticalPadding="0px"Font-Size="10pt"Font-Names="Tahoma"></NodeStyle>

</asp:TreeView>

I am adding nodes per users request using following code, which is same for depth 0,1 and 2.

newNode.Expanded =false;

newNode.ShowCheckBox =false;

newNode.PopulateOnDemand =true;newNode.SelectAction =TreeNodeSelectAction.Select;

treeNode.ChildNodes.Add(newNode);

sg20000:

is there something I am missing

You are missing, that the treeview is not supported in the updatepanelTongue Tied

Check here:

UpdatePanel Control Overview


Maybe you are right and thanks for your help.

I found at some places forward slash was being used, i fixed that and while trying to make it work, made some other changes to node before adding to tree and seems like it is working. I think some nodes had / (creating some escape sequences) or something else to trigger wrapping of tree.

is that treeview on update panel will behave unpredictablly or there are some other issues?


sg20000:

is that treeview on update panel will behave unpredictablly or there are some other issues?

I'm also using treeview with updatepanel, regardless is it not supported.

Main issue which I found that the tree state (selected node, expanded/collapsed nodes state etc.) stays out sync when a postback occurs. Especially when you use any client side capability (populate on demand, enableclientscript=true).

For example:

- Treeview in up

- User coll/exp nodes (no postback yet)

- User select a node, partial postback, selectednodechanged handled for example.

- User select a different node, same as before, but coll/exp state messed up.

- etc.

Without client script features it's ok in up, but slow (big complicated markup, big viewstate etc.)

Treeview in Updatepanel gets lost when selecting node

We moved to the Beta and then our treeviews in updatepanels started acting strangely. Especially when a node was selected in a treeview that was populated in code after the first page load. It "randomly" collapses and expands nodes as you select a node. Its like its viewstate is messed up or ...

This behavior doesn't occur if the whole treeview i expanded when finished populating it. But it doesn't look so good if it's all expanded. Does anyone know how to collapse all nodes client side ? Cause that might be a workaround - serverside expand all nodes after populating and then clientside collapsing them - server side collapsing gives the random behaivor back !

I read some articles about how the treeviews scripts aren't registered in the scriptmanager which is required in Beta 1. And how treeviews i update panels aren't supported since the rarely are used that way. But the app doesn't look so good when a frequently used treeview causes a full postback of the page just to select a node - which Atlas updatepanel handled great and pretty quick in the AJAX Beta it doesn't work as well at all and is much slower.

Does anyone have the same problem or better yet a workaround while waiting for AJAX updatepanel supporting a treeview

We are having the same problem with the RC release. I didn't try it with other releases.

I use this script to open/close the treeview, with a little adjustment it should work for you too. Hope it helped

function

CloseTree(treeId)

{

//childnodes are contained in divsvar subDivs = document.getElementById(treeId).getElementsByTagName("div");for (i=0; i<subDivs.length; i++)

{

//tree lines are images contained in divs also, so we don't hide them because they will not be shown when the node is toggled into viewif (subDivs[i].id.length >0)

{

subDivs[i].style.display =

'none';

}

}

var imgs = document.getElementById(treeId).getElementsByTagName("img");for (j=0; j<imgs.length; j++ )

{

if ( imgs[j].alt.indexOf("Collapse") >=0 )

{

imgs[j].src = <%=

"'" + Page.ResolveURL("~/") +"'"%>+"Images/tree_collapsed.gif";

imgs[j].alt = imgs[j].alt.replace(

"Collapse","Expand");

}

}

}

function OpenTree(treeId)

{

//childnodes are contained in divsvar subDivs = document.getElementById(treeId).getElementsByTagName("div");for (i=0; i<subDivs.length; i++)

{

subDivs[i].style.display =

'block';

}

var imgs = document.getElementById(treeId).getElementsByTagName("img");for (j=0; j<imgs.length; j++ )

{

if ( imgs[j].alt.indexOf("Expand") >=0 )

{

imgs[j].src = <%=

"'" + Page.ResolveURL("~/") +"'"%> +"Images/tree_expanded.gif";

imgs[j].alt = imgs[j].alt.replace(

"Expand","Collapse");

}

}

}


I have the same issue. Were you able to resolve it? Would appreciate any feed back.

Grewal.

Monday, March 26, 2012

Treeview is slow to respond when a node is selected

I am working on an application that is using the TreeView.

Theway it's functions is the tree displays all the available families offunds. When the node is expanded, it shows the funds for thatparticular family (PopulateOnDemand is set to true). When the fund isclicked, it's added to a checkbox list. It's working, but when the fundis getting added to the checkbox list it's very, very slow. I'd like to get rid of the lag, because it's pretty unusable at this state

I am posing my code, and i hope someone can help me

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="Copy of Default.aspx.cs"
Inherits="_Default" %
<%@dotnet.itags.org. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<link href="Local_Resources/StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<table>
<tr>
<td valign="top">
<cc1:TabContainer ID="TabContainer1" runat="server" Width="460px" Height="400px" ScrollBars="Auto">
<cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="Browse Funds">
<ContentTemplate>
<asp:UpdatePanel runat="server" UpdateMode="conditional" ID="tvUpdatePanel">
<ContentTemplate>
<asp:TreeView ID="TreeView1" OnTreeNodePopulate="PopulateNode" OnSelectedNodeChanged="SelectNode" ExpandDepth="0" runat="server">
<Nodes>
<asp:TreeNode Text="root" SelectAction="Expand" PopulateOnDemand="true" />
</Nodes>
</asp:TreeView>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>
</td>
<td valign="top">
<asp:UpdatePanel runat="server" ID="upResult" UpdateMode="Always">
<ContentTemplate>
<div class="checkboxListWrapper">
<asp:CheckBoxList ID="cblResults" runat="server" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partialclass _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{

}
}

protected void PopulateNode(object source, TreeNodeEventArgs e)
{
switch (e.Node.Depth)
{
case 0:
GetFundFamilies(e.Node);
break;
case 1:
GetFundsByFamily(e.Node);
break;
}
}
protected void GetFundFamilies(TreeNode node)
{
foreach (DataRow drin DAL.getAllFundFamilies().Tables[0].Rows)
{
TreeNode tempNode =new TreeNode(dr[1].ToString(), dr[0].ToString());
tempNode.SelectAction = TreeNodeSelectAction.Expand;
tempNode.PopulateOnDemand =true;
node.ChildNodes.Add(tempNode);
}
}
protected void GetFundsByFamily(TreeNode node)
{
foreach (DataRow drin DAL.getFundsByFamily(node.Value.ToString()).Tables[0].Rows)
{
TreeNode tempNode =new TreeNode(dr[1].ToString(), dr[0].ToString());
node.ChildNodes.Add(tempNode);
}
}
protected void SelectNode(object sender, EventArgs e)
{
TreeView tv = (TreeView)sender;
ListItem li =new ListItem(tv.SelectedNode.Text, tv.SelectedNode.Value);
cblResults.Items.Add(li);

}

}

TreeViews are supported in update panels. You can kind of use them, BUT you will get errors if you try to change a treeview after the initial pageload. If it doesn't change, you should be able to use a treeview inside an update panel without errors. Menus and report viewers are also not supported.

Well, that doesn't answer my question. My tree works just fine. It's just very slow.

When doing some testing i found that when i click on a node, it looks like the entire tree reloads. I don't think i have that problem when i am not using the UpdatePanel, but that defeats the purpose.


Well, that doesn't answer my question. My tree works just fine. It's just very slow.

When doing some testing i found that when i click on a node, it looks like the entire tree reloads. I don't think i have that problem when i am not using the UpdatePanel, but that defeats the purpose.


My point was that you CAN'T get Ajax functionality with the built in Treeview. If you want that, you need a 3rd party control.

in that case i am confused

if it would work, it would just not work. My problem is that it IS working. I just need it to be faster.

I am guessing you mean it doesn't support asynchronous postback? But i can the child nodes to populate on demand without a page reload. If i can't get the tree to work, i can just adapt a GridView for my purposes, or just write a custom control. I don't need too much functionality.


You would probably want to adapt the gridview then. Since the Beta releases, treeviews haven't worked well, if at all when you try to do anything dynamic with them after the initial page load. Before the betas, there was a way to do this, but there were big changes that changed that. We spent a lot of time trying to get it to load dynamically when we were switching our site from the July CTP to releases after that.

that's what i am trying to do right now actually

even with a gridview it's tricky and i ran into the same problem of the whole grid expanding when a node is clicked

i guess i need to add multiple update panels to make it work

Treeview Malfunction In Update panel

If I put a treeview in an update pannel and put any code in its expand /collapse methods the treeview closes the previous node that you expand. This is fine but when I expand a node and try to collapse that same node it does not collapse but rather stay expanded. Therefore I gathered it does the opposite action to the previously clicked node.

Why does this happen in the update panel, it doesn't happen without it?

The treeview control is not supported officially in the updatepanel!

One problem is that (I think) the treeview use hidden fields to maintain the expanded state of the nodes, and that hidden field stay out of the sync (especially when you use EnableClientScript="true" also). There are tons of other treeview features which not works correctly in the updatepanel.

Treeview not working in Beta 1.0?

I have a treeview that used to work in CTP July version but stopped working after I installed the beta version.

The first problem: say I have node A and it has at least one child. If I expand node A (by clicking the + button) then click on the name of the node, it readds the children, effectively doubling the number of the nodes. I could continue adding the children of the nodes resulting is multiple children being added.

The second problem relates to the first one. Expand node A, expand node B, select node B then select one of node B's child. Somehow one of node A's child is expanded.

The third one: I can't expand more than two levels. Everytime I try to do it, this error message appears:

Line: 82
Error: 'undefined' is null or not an object

Looking at source, the line that breaks it is this:

table.insertAdjacentHTML("afterEnd", chunk);

All of the nodes have PopulateOnDemand = true. Am I doing something totally wrong or is it really a bug in the beta 1.0? Every other controls (including the ones from value pack) seems to work properly except this treeview. :(

For reference here's what I have on the aspx page:

<div class="BrowserTreeView">
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TreeView ID="tvDirectory" runat="server" OnTreeNodePopulate="PopulateNode" OnPreRender="tvDirectory_PreRender" OnSelectedNodeChanged="tvDirectory_SelectedNodeChanged" SkinID="Explorer"></asp:TreeView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostbackTrigger ControlID="cmbComputer" EventName="SelectedIndexChanged"></asp:AsyncPostbackTrigger>
<asp:AsyncPostbackTrigger ControlID="cmdOpen" EventName="Click"></asp:AsyncPostbackTrigger>
</Triggers>
</asp:UpdatePanel>
</div>

Please see these two articles:

- What's up with UpdatePanels and how come nothing works? (http://forums.asp.net/thread/1440058.aspx)
This is a higher level piece that explains how UpdatePanel changed from being automatic (and broken) in the CTP to the new functionality in the beta.

- HOWTO: Write controls compatible with UpdatePanel without linking to the ASP.NET AJAX DLL (http://forums.asp.net/thread/1445844.aspx)
This article goes in depth on how to use the new registration APIs on ScriptManager, but without linking to the Atlas assembly.

Thanks,

Eilon


Thanks. I didn't know that treeview is not supported yet.

treeview updatepanel problem

hi,

i have a treeview inside an updatepanel. I'm using ajax ext beta 1

the treeview make use of the node expand with PopulateOnDemand = True

when i select a leaf node the treeeview is regenerated with one or more node that i have not added and than stop working.

I think this is a problem of the treeview with updatepanel because if I remove the updatepanel the treeview work fine.

can anyone help me to solve the problem?

thanks

this is the source code...

Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.LoadIf Not Page.IsPostBackThen trv1.Nodes.Clear() trv1.Nodes.Add(New XTreeNode("Root node","A")) trv1.Nodes(0).ChildNodes.Add(New XTreeNode("trv1_node 1","1.1")) trv1.Nodes(0).ChildNodes.Add(New XTreeNode("trv1_node 2","1.2"))'trv1.Nodes(0).ChildNodes(0).Select() trv1.Nodes(0).ChildNodes(0).PopulateOnDemand =True trv1.Nodes(0).ChildNodes(0).SelectAction = TreeNodeSelectAction.Expand trv1.ExpandDepth = 1End If End Sub Protected Sub trv1_TreeNodePopulate(ByVal senderAs Object,ByVal eAs System.Web.UI.WebControls.TreeNodeEventArgs)Handles trv1.TreeNodePopulateDim pNodeAs TreeNode = e.NodeDim pNewNodeAs TreeNode =New TreeNode("New Node","NN") pNewNode.PopulateOnDemand =True pNewNode.SelectAction = TreeNodeSelectAction.Expand pNode.ChildNodes.Add(pNewNode)End Sub

i've tried also the beta 2 but the problem remains the same!!

can anyone help me to solve the problem?


I heard it isn't supported with the Betas or RC, but I heard it may be eventually... I did work before the Betas though.

Treeview, how to remove style on preselected node

In my .NET 2.0 project and I'm using a TreeView with Atlas so the page doesn't postback. When the page loads the first time, it also preselect a node based on a value saved in the DB. The style applied on this node doesn't change when user selects another node. However, the style on the node user selected is removed once user selects another node. I'm guessing there's a javascript variable I need to set on page load?

T"he style applied on this node doesn't change when user selects another node. However, the style on the node user selected is removed once user selects another node."

So the node loses it style when what occurs? I'm not quite sure what you mean by that?
Just so you know though the TreeView control doesn't cause a postback in terms of navigating through the tree. If you need to apply a certain style to the TreeView just look at the options for it here.

http://www.asp.net/QuickStart/aspnet/doc/ctrlref/navigation/treeview.aspx

That should give you a good starting place for how to work with the TreeView control both on the server side and client.

JoeWeb

TreeView, UpdatePanel PopulateOnDemand problem

When I use a PopulateOnDemand TreeView inside an UpdatePanel - when I click on the root node to populate its immediate children, it expands with the child nodes displayed. If I then click on any of the child nodes, the root node collapses. This does not happen if not in an UpdatePanel.

Also, if I click on the root node again and then click on an immediate child to populate its children, it has the same behavior. After the root node automatically collapses, if I click on the root node again, all child nodes that were expanded will still be expanded.

Does anyone know how I can get the root node to not automatically collapse when I click on any of its descendent nodes?

The TreeView isn't supported inside an UpdatePanel, see the last bullet point on this blog and follow the UpdatePanel doc link:http://blogs.visoftinc.com/archive/2007/09/23/asp.net-ajax--updatepanel-not-working--common-problems.aspx

PopulateOnDemand PopulateNodesFromClient actually uses client script as it is.

-Damien


Thanks for the response. When you say that it uses client script, what does that mean? PopulateOnDemand seems to cause full page refreshes - even when I use EnableClientScript and PopulateNodesFromClient...


That's what PopulateNodesFromClient does:http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.treeview.populatenodesfromclient.aspx.

The example states:"The following code example demonstrates how to use thePopulateNodesFromClient property to enable client-side population of the nodes in theTreeView control. Notice that when client-side node population is enabled, nodes are populated dynamically on the client, without the need to post back to the server."

-Damien


Thanks. My point was that it still caused a full page refresh. If it was happening on the client (using Ajax), then I wouldn't see a full page refresh. It turns out that I had to take out my TreeNodeExpanded and TreeNodeCollapsed event handlers to get rid of the full page refresh. After doing that, though, child nodes (that definitely have a parent node) have their Parent property set to null.

I am making headway though...thanks for your help.


You may want to check out this:http://steveorr.net/articles/Ajax.aspx

-Damien


Thanks. Good article. But it still does not explain why the Parent property is null on a child node. Again, this only happens with EnableClientScript, PopulateNodesFromClient and without TreeNodeExpanded and TreeNodeCollapsed event handlers. I need the Parent node for context so I can populate nodes more than 2 deep.