using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class TreeView_UpdatePanel : System.Web.UI.Page
{
    //Global variables
    protected static string Skin = "";
    protected static string Structure = "";


    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptManager sm = ScriptManager.GetCurrent(Page);

        //Set defaults
        if (sm.IsInAsyncPostBack == false &&
            Page.IsCallback == false &&
            Page.IsPostBack == false)
        {
            Skin = "Classic";
            Structure = "Default.xml";
        }

        //Check defaults
        if (Skin == "") Skin = "Classic";
        if (Structure == "") Structure = "Default.xml";

        BuildControl();
    }


    protected void Button1_Click(object sender, EventArgs e)
    {
        Skin = "Outlook";
        Structure = "Outlook.xml";
        BuildControl();

        //Open the first node
        myTreeView.Elements["i1"].opened = true;
    }


    protected void Button2_Click(object sender, EventArgs e)
    {
        Skin = "IconsFolders";
        Structure = "IconsFolders.xml";
        BuildControl();
    }


    private void BuildControl()
    {
        myTreeView.SkinFolder = "~/TreeView/Skins/" + Skin;
        myTreeView.StructureFileURL = "~/TreeView/Structures/" + Structure;
        myTreeView.DataBind();
    }

}