[CLOSED] Add panel from codebehind

  1. #1

    [CLOSED] Add panel from codebehind

    Hi,

    Im trying to add a panel object from codebehind. When i compile and run the page nothing shows. How can solve this?

    
    
    
    protected void Page_Load(object sender, EventArgs e)
    {
        for (int i = 0; i < 2; i++)
        {
            Coolite.Ext.Web.Panel pnlTest = new Coolite.Ext.Web.Panel();
            pnlTest.Title = i.ToString();
            pnlTest.ID = i.ToString();
            pnlTest.Html = "Content " + i;
            divTest.Controls.Add(pnlTest);
        }
    }
    
    
    
    
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test2.aspx.cs" Inherits="Test2" %>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title>Untitled Page</title>
    </head>
        <body>
            <form id="form1" runat="server">
    
                <ext:ScriptManager ID="ScriptManager1" runat="server">
                </ext:ScriptManager>
                
                <div runat="server" id="divTest"> 
                
    
    
            </form>
        </body>
    </html>
    Best regards
    Mikael
  2. #2

    RE: [CLOSED] Add panel from codebehind

    Hello,

    Here is a simplified example of what you are trying to achieve:

    <%@ Page Language="C#" %>
    <%@ Register assembly="Coolite.Ext.Web" namespace="Coolite.Ext.Web" tagprefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            Coolite.Ext.Web.Panel pnlTest = new Coolite.Ext.Web.Panel();
    
            pnlTest.Title = "Test";
            pnlTest.Html = "Hello World";
            
            pnlParent.Controls.Add(pnlTest);
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>Word</title>
    </head>
    <body>
        <p><a href="Example.aspx">Reload</a></p>
        <form id="form1" runat="server">
            <ext:ScriptManager ID="ScriptManager1" runat="server" />
            <asp:PlaceHolder ID="pnlParent" runat="server" />
        </form>
    </body>
    </html>
    Don't set the ID of the new Ext:Panel to a number, it won't work :)

    Cheers,
    Timothy
  3. #3

    RE: [CLOSED] Add panel from codebehind

    Hi,

    Thanks, now it is working. The problem was my Panel.ID which didnīt accept numeric values only.

    Best regards
    Mikael

Similar Threads

  1. [CLOSED] Panel with columnLayouts codebehind don't working
    By ViDom in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 13, 2012, 8:40 AM
  2. Treegrid codebehind to Tab Panel
    By JGF in forum 1.x Help
    Replies: 0
    Last Post: Mar 07, 2012, 3:04 AM
  3. [CLOSED] Calendar Panel Localization problem in codebehind
    By jcanton in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Oct 05, 2011, 4:00 PM
  4. AddListener for Ext.Panel Runtime from codebehind
    By Journeyman79 in forum 1.x Help
    Replies: 1
    Last Post: Apr 04, 2011, 2:38 PM
  5. Replies: 3
    Last Post: Apr 21, 2009, 6:19 PM

Posting Permissions