Treeview|web
First, thank Shi for pointing out how I can reuse the TreeView, the Microsoft IE WebControl. For more information, see http://community.csdn.net/Expert/TopicView.asp?id=3365114
IE WebControl can be used in HTML files alone or in Web form. NET programs;
For the latter, the use of the program can be added to the node, can also be bound;
For the latter, when binding, you can help set an XML-formatted string, or bind an XML file, as long as you assign a value to the TreeNodeSrc property of the TreeView control;
For the latter, there are two possibilities, one that is bound to an XML file that already exists on the hard disk, or that the TREENODESRC value is set to ".../foo.xml", and the other is to create an ASPX page that dynamically produces an XML-formatted output that is bound to this page.
For the latter, an error is generated.
The reason is that the TreeView control actually has two places to bind, or to parse a data source to produce a tree structure, one in the server Side, and one in the browser Side. In the process of render the TreeView control, if you find that TREENODESRC is an address, it will attempt to read the contents of this address and then parse and explicitly write to the output of the Web page, where an error is generated.
My solution is to define an extended attribute Treenodesrca, which is not parsed on the server side, but is written to browser side, and then the TreeView's HTC reads the contents of the Treenodesrca-pointing URL and parses it.
The specific steps are as follows:
First, in the TreeView of the source program Treeview.cs file
public class Treeview:basepostbackcontrol
Part of the section to join such a
<summary>
URL of the XML file to import as the TreeNode content of the tree, Browser Side Binding
</summary>
[
Category ("Data"),
DefaultValue (""),
PersistenceMode (Persistencemode.attribute),
Resdescription ("Treenodesrca"),
]
public string Treenodesrca
{
Get
{
Object str = viewstate["Treenodesrca"];
return ((str = null)? String.Empty: (string) str);
}
Set
{
viewstate["Treenodesrca"] = value;
}
}
Its function is to define a property called Treenodesrca.
Second, in the TreeView source program Treeview.cs File
function Gettreenodesrca ()
{
return Prop_treenodesrca;
}
function Settreenodesrca (value)
{
if (Prop_treenodesrca!= value)
{
Prop_treenodesrca = value;
}
}
This is the description that defines an HTC attribute, sets the variable to store, and sets the way to read and write it.
Five, in the TreeView script file Treeview.htc function Oncontentready (), in the
if (treenodesrc!= null)
Before, join:
if (Treenodesrca!= null)
TREENODESRC = Treenodesrca;
This guarantees that when creating, if the extended attribute is Treenodesrca, it will be used to fill the treenodesrc, then browser will read the data source and parse, bind.
"Athossmth Original, reprint please specify, thank you"
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.