Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls

Partial Public Class TreeView_UpdatePanel
    Inherits System.Web.UI.Page
    'Global variables
    Protected Shared Skin As String = ""
    Protected Shared [Structure] As String = ""


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        Dim sm As ScriptManager = ScriptManager.GetCurrent(Page)

        'Set defaults
        If sm.IsInAsyncPostBack = False AndAlso Page.IsCallback = False AndAlso Page.IsPostBack = False Then
            Skin = "Classic"
            [Structure] = "Default.xml"
        End If

        'Check defaults
        If Skin = "" Then
            Skin = "Classic"
        End If
        If [Structure] = "" Then
            [Structure] = "Default.xml"
        End If

        BuildControl()
    End Sub


    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
        Skin = "Outlook"
        [Structure] = "Outlook.xml"
        BuildControl()

        'Open the first node
        myTreeView.Elements("i1").opened = True
    End Sub


    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs)
        Skin = "IconsFolders"
        [Structure] = "IconsFolders.xml"
        BuildControl()
    End Sub


    Private Sub BuildControl()
        myTreeView.SkinFolder = "~/TreeView/Skins/" & _
            Skin
        myTreeView.StructureFileURL = "~/TreeView/Structures/" & _
            [Structure]
        myTreeView.DataBind()
    End Sub

End Class