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