By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,403 Members | 880 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,403 IT Pros & Developers. It's quick & easy.

Dynamic TreeView loses PopulateOnDemand

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.