473,769 Members | 5,885 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic TreeView loses PopulateOnDeman d

Hi,

I'm working on a pagination control and I need to dynamically rerender
a treeview to display the next set of nodes depending on which page
we're on. For example, page 1 will dispaly only nodes 1 to 10, but
when the user clicks [next], the tree will display nodes 11 to 20.

Page 1 will is loaded when the page that contains the ascx (parent of
the treeview) is loaded. This is all cool. The treeview displays
correctly. When I click the [+] to expand a node, the node expands and
its children are populated on demand. But whenever a new page is
displayed, that is a new rendering of the user control that has the
treeview now populated with the next set of nodes, expanding a node
does a post back; it loses its ability to populate on demand.

To get the next set of nodes for my pagination control, i've
implemented the ICallbackEventH andler on the user control that hosts
the treeview. (because I'll be updating other controls such as
textboxes, etc based on the page number as well). In the
RaiseCallbackEv ent, i have the logic to clear the nodes and repopulate
the treeview with the new nodes...
void RaiseCallbackEv ent(String eventArgument)
{
int index = Convert.ToInt32 (eventArgument) ;
lbPageNumber.In nerText = index.ToString( );
LoadPage(index, 4); //method for clearing nodes and getting new
node data from db
}
and in the GetCallbackResu lt method, i render the ascx control to an
htmlwriter so that i can send back its html representation. ..
String ICallbackEventH andler.GetCallb ackResult()
{
System.Text.Str ingBuilder sb = new System.Text.Str ingBuilder();
HtmlTextWriter wr = new HtmlTextWriter( new StringWriter(sb ));
foreach (Control c in this.Controls)
{
c.RenderControl (wr);
}
return sb.ToString();
}

No errors are thrown, but when i display this html to the page or
section that will display it, clicking on the [+] signs to expand the
nodes does a postback rather than a callback to populate the nodes on
demand. Does anybody have a clue as to why RenderControl strips out
the treeview's callback scripts from the html??

Dec 22 '06 #1
1 4935
Something similar perhaps

I have the following problem:

an asp.net treeview for which an initial set of nodes are retrieved and

subsequently on expand the child nodes are retrieved once

for the initial set of nodes asp.net produces an 'javascript:onc lick()' in

the anchor element of each of these nodes that allows getting the selected

node later, the onclick handler 'remembers' the selected node for later use

and is generated by asp.net (webresource.as d or something like that)

for the childnodes retrieved later it does not produce this snip

how can I make these childnodes have this snip as well without resorting to

filtering and patching the output towards the client?

many thanks in advance

<do****@gmail.c omwrote in message
news:11******** **************@ f1g2000cwa.goog legroups.com...
Hi,

I'm working on a pagination control and I need to dynamically rerender
a treeview to display the next set of nodes depending on which page
we're on. For example, page 1 will dispaly only nodes 1 to 10, but
when the user clicks [next], the tree will display nodes 11 to 20.

Page 1 will is loaded when the page that contains the ascx (parent of
the treeview) is loaded. This is all cool. The treeview displays
correctly. When I click the [+] to expand a node, the node expands and
its children are populated on demand. But whenever a new page is
displayed, that is a new rendering of the user control that has the
treeview now populated with the next set of nodes, expanding a node
does a post back; it loses its ability to populate on demand.

To get the next set of nodes for my pagination control, i've
implemented the ICallbackEventH andler on the user control that hosts
the treeview. (because I'll be updating other controls such as
textboxes, etc based on the page number as well). In the
RaiseCallbackEv ent, i have the logic to clear the nodes and repopulate
the treeview with the new nodes...
void RaiseCallbackEv ent(String eventArgument)
{
int index = Convert.ToInt32 (eventArgument) ;
lbPageNumber.In nerText = index.ToString( );
LoadPage(index, 4); //method for clearing nodes and getting new
node data from db
}
and in the GetCallbackResu lt method, i render the ascx control to an
htmlwriter so that i can send back its html representation. ..
String ICallbackEventH andler.GetCallb ackResult()
{
System.Text.Str ingBuilder sb = new System.Text.Str ingBuilder();
HtmlTextWriter wr = new HtmlTextWriter( new StringWriter(sb ));
foreach (Control c in this.Controls)
{
c.RenderControl (wr);
}
return sb.ToString();
}

No errors are thrown, but when i display this html to the page or
section that will display it, clicking on the [+] signs to expand the
nodes does a postback rather than a callback to populate the nodes on
demand. Does anybody have a clue as to why RenderControl strips out
the treeview's callback scripts from the html??

Dec 23 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1015
by: Tony Sedgwick | last post by:
I've created a treeview that sits in a separate frame to the main frame and is loaded dynamically from a SQL db. Everything was working fine until I needed a node that could both Expand to retrieve data via an xml-http postback AND also load a page into another frame. The properties I have set on the node are: ..PopulateOnDemand = True
1
3318
by: Mark | last post by:
Hello, I am using the new TreeView in ASP.Net 2.0. I am using its PopulateOnDemand feature. The problem is that the treeviews +/- images, and any checkboxes, have the tooltip set. If the node contains HTML, then the tooltip shows the raw HTML, which is unacceptable to users. Is there any way to block the tooltips from displaying this HTML?
0
2297
by: drop | last post by:
Hi, I'm currently working with the Treeview control in ASP .Net 2.0. The tree is filled dynamically based on data contained in a MySQL Database. Here is the exact behavior I want : 1 - User clicks on a node to expand it. 2 - Add a child node to the node clicked by the user saying the tree is loading that part. So here, I also need to expand the node clicked by
1
5612
by: aaronh64 | last post by:
I'm trying to bind to the ASP.NET TreeView control and utilize the PopulateOnDemand functionality. However, I am receiving the following (very confusing) error: "PopulateOnDemand only supported when binding the TreeView to a data source control using the DataSourceID property or when the TreeNodePopulate event is handled." Here is the code within my page load handler: if (!IsPostBack) {
2
5511
by: makennedy | last post by:
Hi Experts, Please help, I am a newbie to ASP.NET 2.0 may be I am doing something wrong or there may be a bug somewhere. Basically I have a TreeView Control which I have created programmatically. And I want to bind the selection of a TreeNode (which is a record) from the database) to a DetailsView which shows the datatable record for the selected TreeView node in the Details View. I am using IDE : Visual Web Developer 2005 Express; OS=...
11
1535
by: pbd22 | last post by:
Hi. I am getting odd treeview results and hope you can help. I am parsing a string, "x/y/z", turning it into an array (that always seems to start with an empty string) and then using the elements of that array to populate a single tree. The first non-empty element is the root, the last is a file - everything in between is a folder.
1
3509
by: Falcula | last post by:
Hello, I have a treeview control, when i select a item i navigate to url. But selected node is lost, it reset itself, loosing state. I post my code here. Thanks in advance. <script language="javascript">
0
1902
by: Falcula | last post by:
Hello, I have a treeview that i fill from a database, when i update nodename in database the treeview dont update. Its works when iam not useing enableviewstate="true" but then i loosing the current selection and stuff in the tree. I post my code here, any idea ?
0
1420
by: =?Utf-8?B?QnJpYW4gTmljaG9sc29u?= | last post by:
Hello, I've created a treeview control that gives a folder browser view of a given computer. The treeview is populated using the following methods: Protected Sub treeDst_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles treeDst.Init Dim dirInfo As New DirectoryInfo("C:\") dstDir.Text = dirInfo.FullName
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3959
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3562
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.