• dnn中COMPONENTART:TREEVIEW 控件的使用(act) dodo


    一、控件页面的设置
    <%@ 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>

    二 后台代码文件
    1.PAGE_LOAD事件
     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. '建立目录数
            Protected Sub BuildTree()
                '获取数据源
                Dim objInfo As New C_InfoController

                Dim dbRow As DataRow

                dsC_InfoModules = objInfo.GetdsC_InfoModules()

                Dim I As Integer

                Dim J As Integer

                '通过循环建立模块所属站点级别的目录

                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.'获取模块所属站点下的页面级别的目录数
     Private Sub PopulateSubTree(ByVal NodeID As String, ByVal NodeName As String, ByVal node As TreeViewNode)
    4. '添加模块级别的选项节点
                        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.创建节点函数
    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
    三 引用该控件的aspx文件设置
    1.页面设置
    <%@ Register TagPrefix="Portal" TagName="TreeModules" Src="~/DesktopModules/C_Info/TreeModules.ascx" %><%@ Register TagPrefix="Portal" TagName="TreeModules" Src="~/DesktopModules/C_Info/TreeModules.ascx" %>
    <portal:treemodules id="TreeModulesMore" runat="server"></portal:treemodules>
    2.后台关键

                       '获取页面子控件页面中的TreeView控件
                       Dim treeViewModules As TreeView = CType(TreeModulesMore.FindControl("TreeViewModules"), TreeView)

                        Dim node As TreeViewNode

                        '遍历TreeView 控件中被选中的节点,并进行相应的操作
                        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

  • 相关阅读:
    Tomcat + Mysql高并发配置优化
    Qt Widget 利用 Qt4.5 实现酷炫透明窗体
    使用VC2005编译真正的静态Qt4.4.3程序 good
    详解 Qt 线程间共享数据(使用signal/slot传递数据,线程间传递信号会立刻返回,但也可通过connect改变)
    浅析在QtWidget中自定义Model(beginInsertRows()和endInsertRows()是空架子,类似于一种信号,用来通知底层)
    英国著名芯片厂商与苹果谈崩 中资收购机会来了!
    跨站脚本攻击(XSS)
    Kafka 协议实现中的内存优化
    读取配置信息
    英语面试准备
  • 原文地址:https://www.cnblogs.com/zgqys1980/p/404481.html
Copyright © 2020-2023  润新知