Using this TreeView is often necessary to do some data operations to do action Postback to the server, such as OnexPanded or SelectIndexchange. The TreeView control provides an AutoPostBack's property to set whether this TreeView needs to perform Postback's actions to make the background operational data. Once this property is set to TRUE, then all the actions of TreeView will go back to refresh the page, no matter whether expand is still SelectIndexchangek, POSTBACK goes back, many times we just need to postback it. If all events are posback, it also affects the user experience but also affects system performance. The way to solve this problem is to handle the Postback of each action. If the condition does not set up, it will not postback, try to reduce unnecessary Postback.
Let's take an example to tell how you control the action of Postback.
Protected Microsoft.Web.ui.WebControls.treeView Tvschema;
Private Void Page_Load (Object Sender, System.EventArgs E)
{
if (! IsPostback) {// event modifications Expand client code string script = @ "javascript: if (! this.clickedNodeIndex = null) {this.queueEvent ( 'onexpand', this.clickedNodeIndex); expandedTable (this, this .clickednodeindex;} "; tvschema.attributes [" onexpand "] = script;} // Register control script
RegistetReescript ();
}
Private void registetReescript ()
{
String script
= @ "
Function ExpandedTable (Sender, _NodeIndex)
{
Var node = sender.gettreenode;
// If there is no child object, you will postback;
IF (node.getchildren (). Length == 0)
" GetPostBackeventReference (tvschema) @";
}
script>
THIS.REGISTERCLIENTScriptBlock ("Tvschema", Script;
}
Private void TVschema_expand (Object Sender, Microsoft.Web.ui.WebControls.TreeViewClickeventargs E)
{
/ / According to the selected target, generate the child tree
}