Apr 20, 2009, 3:06 PM
TreePanel can not show in codebehind
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
InitGUI();
}
protected void InitGUI()
{
TreePanel tree = new TreePanel();
tree.Title = "Online Users";
tree.RootVisible = false;
tree.Tools.Add(new Tool(ToolType.Refresh, "Ext.Msg.alert('Message','Refresh Tool Clicked!');", ""));
Coolite.Ext.Web.TreeNode root = new Coolite.Ext.Web.TreeNode();
root.NodeID = "root";
tree.Root.Add(root);
Coolite.Ext.Web.TreeNode node1 = new Coolite.Ext.Web.TreeNode();
node1.Text = "Friends";
node1.Expanded = true;
node1.Nodes.Add(new Coolite.Ext.Web.TreeNode("Jack", Icon.User));
node1.Nodes.Add(new Coolite.Ext.Web.TreeNode("Brian", Icon.User));
node1.Nodes.Add(new Coolite.Ext.Web.TreeNode("Jon", Icon.User));
node1.Nodes.Add(new Coolite.Ext.Web.TreeNode("Tim", Icon.User));
node1.Nodes.Add(new Coolite.Ext.Web.TreeNode("Nige", Icon.User));
node1.Nodes.Add(new Coolite.Ext.Web.TreeNode("Fred", Icon.User));
node1.Nodes.Add(new Coolite.Ext.Web.TreeNode("Bob", Icon.User));
root.Nodes.Add(node1);
Coolite.Ext.Web.TreeNode node2 = new Coolite.Ext.Web.TreeNode();
node2.Text = "Family";
node2.Expanded = true;
node2.Nodes.Add(new Coolite.Ext.Web.TreeNode("Kelly", Icon.UserFemale));
node2.Nodes.Add(new Coolite.Ext.Web.TreeNode("Sara", Icon.UserFemale));
node2.Nodes.Add(new Coolite.Ext.Web.TreeNode("Zack", Icon.UserGreen));
node2.Nodes.Add(new Coolite.Ext.Web.TreeNode("John", Icon.UserGreen));
root.Nodes.Add(node2);
//////////////////
// NORTH REGION //
//////////////////
// Make Panel for South Region
Coolite.Ext.Web.Panel north = new Coolite.Ext.Web.Panel();
north.ID = "NorthPanel";
north.Title = "??????";
north.Height = Unit.Pixel(100);
north.BodyStyle = "padding:1px;";
north.Collapsible = false;
/////////////////
// WEST REGION //
/////////////////
// Make Panel for West Region
Coolite.Ext.Web.Panel west = new Coolite.Ext.Web.Panel();
west.ID = "WestPanel";
west.Title = "????";
west.Width = Unit.Pixel(225);
// Make TabPanel for East Panel
TabPanel tpEast = new TabPanel();
tpEast.ActiveTabIndex = 2;
tpEast.TabPosition = TabPosition.Bottom;
tpEast.Border = false;
tpEast.Height = 500;
// Make Tab 1
Tab tabEast1 = new Tab();
tabEast1.Title = "????";
tabEast1.Border = false;
tabEast1.BodyStyle = "padding:1px;";
tabEast1.Items.Add(tree);
//tabEast1.Html = "East Tab 1";
// Make Tab 2
Tab tabEast2 = new Tab();
tabEast2.Title = "????";
tabEast2.Border = false;
tabEast2.BodyStyle = "padding:1px;";
//tabEast2.Html = "East Tab 2";
// Make Tab 3
Tab tabEast3 = new Tab();
tabEast3.Title = "????";
tabEast3.Border = false;
tabEast3.BodyStyle = "padding:1px;";
// Add FitLayout container to East Panel
// Make Navigation Panel for Accordion
Coolite.Ext.Web.Panel pnlNavigation = new Coolite.Ext.Web.Panel();
pnlNavigation.ID = "Navigation";
pnlNavigation.Title = "????";
pnlNavigation.Border = true;
pnlNavigation.BodyStyle = "padding:1px;";
pnlNavigation.Icon = Icon.FolderGo;
// Make Settings Panel for Accordion
Coolite.Ext.Web.Panel pnlSettings = new Coolite.Ext.Web.Panel();
pnlSettings.ID = "Settings";
pnlSettings.Title = "????";
pnlSettings.Border = false;
pnlSettings.BodyStyle = "padding:1px;";
pnlSettings.Icon = Icon.FolderWrench;
//pnlSettings.Html = "Some settings in here";
// Make Accordion container
Accordion acc = new Accordion();
acc.Animate = true;
// Add Navigation and Settings Panels to Accordion
acc.Items.Add(pnlNavigation);
acc.Items.Add(pnlSettings);
// Add Accordion to West Panel
tabEast3.Items.Add(acc);
// Add Tab's to East TabPanel
tpEast.Tabs.Add(tabEast1);
tpEast.Tabs.Add(tabEast2);
tpEast.Tabs.Add(tabEast3);
// tpEast.SetActiveTab(2);
// Make new FitLayout container
FitLayout fit = new FitLayout();
// Add TabPanel East to FitLayout
fit.Items.Add(tpEast);
west.Items.Add(fit);
///////////////////
// CENTER REGION //
///////////////////
// Make TabPanel for Center Region
TabPanel center = new TabPanel();
center.ID = "CenterPanel";
center.ActiveTabIndex = 0;
// Make Tab
Tab tab1 = new Tab();
tab1.ID = "Tab2";
tab1.Title = "Center";
tab1.Border = false;
tab1.BodyStyle = "padding:1px;";
tab1.Items.Add(tree);
Toolbar toolbar = new Toolbar();
Coolite.Ext.Web.Button button1 = new Coolite.Ext.Web.Button();
button1.Icon = Icon.Connect;
ToolTip tooltip = new ToolTip();
tooltip.Title = "Rich ToolTips";
tooltip.Html = "Let your users know what they can do!";
button1.ToolTips.Add(tooltip);
Coolite.Ext.Web.Button button2 = new Coolite.Ext.Web.Button();
button2.Icon = Icon.UserAdd;
button2.AjaxEvents.Click.Event += new ComponentAjaxEvent.AjaxEventHandler(Click_Event); //= "Coolite.AjaxMethods.SetTimeStamp();";
Coolite.Ext.Web.Button button3 = new Coolite.Ext.Web.Button();
button3.Icon = Icon.UserDelete;
toolbar.Items.Add(button1);
toolbar.Items.Add(button2);
toolbar.Items.Add(button3);
center.BottomBar.Add(toolbar);
// Add Tab's to TabPanel
center.Tabs.Add(tab1);
//////////////
// VIEWPORT //
//////////////
// Make BorderLayout container for ViewPort
BorderLayout layout = new BorderLayout();
// Set North Region properties
layout.North.Split = true;
layout.North.Collapsible = true;
// Set West Region properties
layout.West.MinWidth = Unit.Pixel(225);
layout.West.MaxWidth = Unit.Pixel(400);
layout.West.Split = true;
layout.West.Collapsible = true;
// Set East Region properties
layout.East.MinWidth = Unit.Pixel(225);
layout.East.Split = true;
layout.East.Collapsible = true;
// Set South Region properties
layout.South.Split = true;
layout.South.Collapsible = true;
// Add Panels to BorderLayout Regions
layout.North.Items.Add(north);
layout.West.Items.Add(west);
layout.Center.Items.Add(center);
// Make ViewPort to fold everything
ViewPort vp = new ViewPort();
vp.ID = "ViewPort1";
// Add BorderLayout to ViewPort
vp.Items.Add(layout);
// Add ViewPort to Form
this.form1.Controls.Add(tpEast);
}
void Click_Event(object sender, AjaxEventArgs e)
{
this.ScriptManager1.AddScript("alert('AjaxEvent: UserParam');");
}
}
this is my code, aspx no control,all in codebhind(poor english),but tree cannt display! Whole page is blank.please help me. thanks.