CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML





Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 3/31/2006 8:04:29 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 3 Views: 7 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
4 Items, 1 Pages 1 |< << Go >> >|
Balthazaar
Asp.Net User
TreeView, OnDemand and server side check-boxes3/31/2006 8:04:29 AM

0/0

Hi all,

this topic is driving me nuts. ;)

With this article: http://aspalliance.com/732 I was able to get my treeview built on demand. If I expand a node, the server retrieves the necessary data froman SQL database (in my case) and then populates the treeview without the need of a postback. Client Callback makes this possible. ;)

Every new node gets a checkbox. Since ASP.NET 2.0 does not add an autopostback to the treeview, the state of the checkboxes can only be seen by the server after a postback triggered somehow else. This does not matter, since I have a Button on my page that finally triggers a postback.

With this article: http://www.webswapp.com/codesamples/viewsource.aspx?file=~/codesamples/aspnet20/treeview/treenodecheckchanged.aspx I would expect, that when this postback is triggered, all checkbox events get noticed by the server and I can gather them.

The Problem now is, that the TreeNodeCheckChanged event seems to be only triggered by the client, when the checkbox was already there when the treeview has been initially rendered. This means that if I populate a node on demand and programmatically add a checkbox, this checkbox doesn't fire a TreeNodeCheckChanged event...

Is there any way to get this properly working?

Of course I can call a serverside ExpandAll and CollapseAll. This would populate the whole treeview at once and then it would work. But this does not make sense, since I would loose all advantages of using the OnDemand feature... :-(

I hope anyone has an answer to this.

Best regards and thanks
for reading this,

Christian.

joteke
Asp.Net User
Re: TreeView, OnDemand and server side check-boxes4/2/2006 8:56:00 AM

0/0

Hi,

thanks for reading my article. :-)

I'm not sure if I understand what you mean. If you let it populate the nodes, add CheckBox to them, and check a dynamically added node (it's CheckBox) and then cause the postback finally, it throws the TreeNodeCheckChanged event, at least in my test scenario (same code as in the article just changed

Private Sub PopulateNodes(ByVal dt As DataTable, ByVal nodes As TreeNodeCollection)

For Each dr As DataRow In dt.Rows

Dim tn As New TreeNode()

tn.Text = dr("title").ToString()

tn.Value = dr("id").ToString()

tn.ShowCheckBox = True

nodes.Add(tn)

'If node has child nodes, then enable on-demand populating

tn.PopulateOnDemand = (CInt(dr("childnodecount")) > 0)

Next

End Sub

And then

Protected Sub TreeView1_TreeNodeCheckChanged(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs) Handles TreeView1.TreeNodeCheckChanged

Response.Write("Check")

End Sub

Now, if you let it dynamically populate the entire tree, check a few checkboxes, and then cause a postback with the button it should throw the event as many times as you have checked nodes.

Or have I misunderstood something? If yes, then please clarify


Thanks,

Teemu Keiski
Finland, EU
Balthazaar
Asp.Net User
Re: TreeView, OnDemand and server side check-boxes4/3/2006 11:47:40 AM

0/0

No you got it all right. The effect I have is, that if I don't submit the fully expanded tree to the client when the page is initially opened, checked events for dynamically populated subnodes do not get fired.

It's like that:

+ O Root Node

I Open "Root Node" and the node is populated on demand to:

- O Root Node
  + O Sub Node

If I check "Sub Node" and hit a postback button, the buttons' event handler is called, but not the TreeNodeCheckChanged event.

Now, if I declare my treeview with the ExpandDepth attribute set to 1, so that the client shows

- O Root Node
  + O Sub Node

immediately, I can check "Sub Node" and on postback, the corresponding TreeNodeCheckChanged event is fired. This is really weird...

Regards,
Christian.

Balthazaar
Asp.Net User
[SOLVED] Re: TreeView, OnDemand and server side check-boxes4/3/2006 2:28:58 PM

0/0

Just a quick note to everyone:

I was able to solve this problem. Some demo code has been published here: http://www.webswapp.com/codesamples/viewsource.aspx?file=~/codesamples/aspnet20/treeview/populateondemand.aspx to demonstrate the populateondemand feature.

With the help of this code I found out, that the code-behind rebuilds the tree on postback to be able to handle the corresponding events. This makes sense. Without tree, no events. I had a mistake in my code. Actually, the database connection to the data source was not available on postback, so the tree couldn't be rebuilt and therefor, the check events couldn't be handled.

I reinitiated the database connection on postback and voila, it worked.

Thanks for your help guys and
best regards,

Christian.

 

4 Items, 1 Pages 1 |< << Go >> >|



Search This Site:


Meet Our Sponsors:



Other Resources:

User name + password prompt - novell.support.groupwise.pda-connect ... User name + password prompt, > ROOT > NEWSGROUP > Novell Forums > novell.support.groupwise.pda-connect, Date: ... treeview, ondemand and server side check-boxes ...
Log files from user chats - novell.support.groupwise.messenger - Web ... ... contacts in server-side contact list ... Check all of the other support tools and options available at ... treeview populate-on-demand expand problem. please take ...
ASP.NET TreeView Control Layout and Behavior. Check boxes. Load On Demand. Expand Single Path. Absolute position ... Server-side API. APNSoft TreeView now provides an extremely rich ...
TreeView Web Server Control Overview When the TreeView control is configured to populate on demand, the control raises an ... Selection, Navigation, and Check Boxes in the TreeView Web Server Control ...
download.microsoft.com/download/D/1/1/... Nodes are navigable, selectable, or static and can include check boxes ... <asp:TreeNode Text="Populate this node on demand" PopulateOnDemand="true" RunAt="server" ...
On .Net, Javascript and more...: Asp.Net 2.0 Treeview Checkbox Check ... Getting TreeNode values on the client side with j... i click the the node name not the check box and the check boxes gets checked? ...
CodeProject: Three State TreeView – Part 1 of 2. Free source code and ... ATL Server. Caching. Charts, Graphs and Images. Client side scripting. Custom ... The .NET 2.0 TreeView control supports the use of check boxes in TreeNodes by ...
TopXML : TreeView with XML Data Binding (.NET Framework) ... and XML .NET and XML .NET and XML Contents. Server-Side Controls ... You can customize fly-over effects, tool tips, node icons and check boxes, for example. ...



 
All Times Are GMT