I. Control page settings
<% @ Register tagprefix = "componentart" namespace = "componentart. Web. UI" assembly = "componentart. Web. UI" %>
<Componentart: Treeview id = "treeviewmodules" runat = "server" lineimagesfolderurl = "images/lines/" showlines = "true"
Leafnodeimageurl = "images/folder.gif" parentnodeimageurl = "images/folders.gif" nodelabelpadding = "3" defaultimageheight = "16"
Defaultimagewidth = "16" lineimageheight = "20" lineimagewidth = "19" nodeeditcssclass = "nodeedit" hovernodecssclass = "hovertreenode"
Selectednodecssclass = "selectedtreenode" nodecssclass = "treenode" cssclass = "Treeview" keyboardenabled = "false"
Nodeeditingenabled = "false" draganddropenabled = "false" enableviewstate = "true" width = "220" Height = "400"> </componentart: Treeview>
2. Background code file
1. page_load event
Private sub page_load (byval sender as system. Object, byval e as system. eventargs) handles mybase. Load
Try
'Put user code to initialize the page here
Buildtree ()
Catch exc as exception
Processmoduleloadexception (Me, exc)
End try
End sub
2. 'number of created Directories
Protected sub buildtree ()
'Obtain the data source
Dim objinfo as new c_infocontroller
Dim dbrow as datarow
Dsc_infomodules = objinfo. getdsc_infomodules ()
Dim I as integer
Dim J as integer
'Establish a site-level directory for the module through Loops
For I = 0 to dsc_infomodules.tables (0). Rows. Count-1
If I = 0 then
Newnode = createnode (CSTR (dsc_infomodules.tables (0 ). rows (0 ). item ("portalname"), CSTR (dsc_infomodules.tables (0 ). rows (0 ). item ("portalid"), true)
'Newnode. Text = CSTR (dsc_infomodules.tables (0). Rows (0). Item ("portalname "))
Treeviewmodules. nodes. Add (newnode)
Populatesubtree ("Tabid", "tabname", newnode)
Else
For J = 0 to I-j-1
If CINT (dsc_infomodules.tables (0 ). rows (J + 1 ). item ("portalid") <> CINT (dsc_infomodules.tables (0 ). rows (j ). item ("portalid") then
Newnode = new treeviewnode
Newnode. Text = CSTR (dsc_infomodules.tables (0). Rows (0). Item ("portalname "))
Treeviewmodules. nodes. Add (newnode)
Populatesubtree ("Tabid", "tabname", newnode)
End if
Next
End if
Next
End sub
3. 'retrieve the number of page-level directories under the website to which the module belongs.
Private sub populatesubtree (byval nodeid as string, byval nodename as string, byval node as treeviewnode)
4. 'add option nodes at the module level
Dim childnode as treeviewnode = createnode (CSTR (dsc_infomodules.tables (0 ). rows (0 ). item ("moduletitle"), CSTR (dsc_infomodules.tables (0 ). rows (0 ). item ("moduleid"), true)
Childnode. showcheckbox = true
Newnode. nodes. Add (childnode)
5. Create a node function
Private function createnode (byval text as string, byval nodevalue as string, byval expanded as Boolean) as treeviewnode
Dim node as treeviewnode = new treeviewnode
Node. Text = text
Node. value = nodevalue
Node. Expanded = expanded
Return Node
End Function
3. Configure the aspx file that references the control
1. Page settings
<% @ Register tagprefix = "Portal" tagname = "treemodules" src = "~ /Topics topmodules/c_info/treemodules. ascx "%>
<Portal: treemodules id = "treemodulesmore" runat = "server"> </Portal: treemodules>
2. Background key
'Get the Treeview control on the page subcontrol page.
Dim treeviewmodules as Treeview = ctype (treemodulesmore. findcontrol ("treeviewmodules"), Treeview)
Dim node as treeviewnode
'Traverse the selected node in the Treeview control and perform corresponding operations
For each node in treeviewmodules. checkednodes
Dim IDS as string = request. querystring ("IDS ")
If IDs <> "" then
Dim objinfo as new c_infocontroller
Select case request. querystring ("type ")
Case "copy"
Case "move"
IDS & = "-1"
Objinfo. movec_info (IDs, CINT (node. Value ))
Response. Write ("<script language = JavaScript> window. opener. Location. Reload (); </SCRIPT> ")
End select
Response. Write ("<script language = JavaScript> window. Opener = NULL; window. Close (); </SCRIPT> ")
End if
Next