PDA

View Full Version : [CLOSED] Can't add dynamically a button to a panel



LuB
Aug 25, 2008, 10:07 AM
Coolite.Ext.Web.Panel panel1 = new Coolite.Ext.Web.Panel();
panel1.ID = "Panel1";
panel1.Title = "Panel 1";
panel1.Border = false;
panel1.BodyStyle = "padding:6px;";
panel1.Icon = Icon.FolderGo;

Coolite.Ext.Web.Button button1 = new Coolite.Ext.Web.Button();
button1.Text = "Button";

//panel1.Controls.Add(button1);
panel1.Items.Add(button1);



(After that, I add panel1 to a accordion menu)

I've tried with panel1.Controls.Add and panel1.Items.Add (what is the difference?), but the button doesn't show when I run the application.

Do you know why it isn't working?

Thanks!

geoffrey.mcgill
Aug 25, 2008, 10:22 AM
Behind door #3 you'll find the .ContentControls Collection. Yes, it's a bit confusing and deciding which collection to use is determined by what you're doing.

In general both the .Controls and .Items Collections/Properties would not used (at least publicly) with the Coolite Toolkit. If you just want to add content to the Panel body, you must add to the <Content> template, which is exposed by the .ContentControls Collection.

The following sample demonstrates adding a Control to the <Content> template of the Panel.


panel1.ContentControls.Add(button1);

Hope this helps.

LuB
Aug 25, 2008, 10:37 AM
Yes, it helps a lot, thanks!

Another question... If I add an icon to the panel (panel1.Icon = Icon.FolderGo; ) I see the icon if I run the application in IE 6 or 7, but it doesn't show if I run it in Firefox 3. It is a bug or I'm doing something wrong?

By the way, I would like to read some Coolite documentation to learn more and not make so stupid questions, there is something I can read?

Thanks!

geoffrey.mcgill
Aug 25, 2008, 4:47 PM
Hi LuB,

Can you provide a Panel sample which does not work in FF3? I develop almost exclusively now in FF3 and have not noticed any issues. The following sample demonstrates a simple <ext:Panel> that I tested with the .Icon property set.

Example


<ext:Panel
ID="Panel1"
runat="server"
Height="300"
Width="600"
Title="Title"
Icon="FolderGo"
Html="Icon Test Panel"
/>

Unfortunately the Coolite Toolkit documentation is not available yet. The full ExtJS documentation (http://www.sencha.com/docs) is available online.

Hope this helps.

LuB
Aug 26, 2008, 3:01 PM
Yeah, it's working now. I think I was doing something wrong.

Thanks for everything.