473,387 Members | 3,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Dynamic TreeView loses PopulateOnDemand

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 ICallbackEventHandler 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
RaiseCallbackEvent, i have the logic to clear the nodes and repopulate
the treeview with the new nodes...
void RaiseCallbackEvent(String eventArgument)
{
int index = Convert.ToInt32(eventArgument);
lbPageNumber.InnerText = index.ToString();
LoadPage(index, 4); //method for clearing nodes and getting new
node data from db
}
and in the GetCallbackResult method, i render the ascx control to an
htmlwriter so that i can send back its html representation...
String ICallbackEventHandler.GetCallbackResult()
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
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 4886
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:onclick()' 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.asd 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.comwrote in message
news:11**********************@f1g2000cwa.googlegro ups.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 ICallbackEventHandler 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
RaiseCallbackEvent, i have the logic to clear the nodes and repopulate
the treeview with the new nodes...
void RaiseCallbackEvent(String eventArgument)
{
int index = Convert.ToInt32(eventArgument);
lbPageNumber.InnerText = index.ToString();
LoadPage(index, 4); //method for clearing nodes and getting new
node data from db
}
and in the GetCallbackResult method, i render the ascx control to an
htmlwriter so that i can send back its html representation...
String ICallbackEventHandler.GetCallbackResult()
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
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
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...
1
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...
0
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...
1
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...
2
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...
11
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...
1
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...
0
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...
0
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...

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.