Dynamic TreeView loses PopulateOnDemand

D

doemon

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??
 
J

John Smith

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:eek:nclick()' 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

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??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top