How to read the value from controls created at runtime? (sample code included)

  1. #1

    How to read the value from controls created at runtime? (sample code included)

    Hi guys, I need to be able to add composite items on-demand during runtime and on a DirectEvent loop through them and read the values inside the controls contained by the composite field but I'm stuck at the reading the values back portion, could you please copy/paste my code and let me know what's the correct approach to do this?
    Thank you,
    Paul

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" 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)
        {
            
        }
    
    
        protected void btAdd_Click(object sender, DirectEventArgs e)
        {
            Ext.Net.CompositeField newField = new Ext.Net.CompositeField();
    
    
            Ext.Net.ComboBox newCombo = new Ext.Net.ComboBox();
            newCombo.Width = new Unit(125);
            newCombo.Margins = "5 5 5 5";
            newField.Items.Add(newCombo);
    
    
            Ext.Net.TextField edtText = new Ext.Net.TextField();
            edtText.Width = new Unit(175);
            edtText.Margins = "5 5 5 5";
            edtText.Text = DateTime.Now.ToString();
            newField.Items.Add(edtText);
    
    
            newField.AddTo(Panel1);
            Panel1.DoLayout();
    
    
            X.Msg.Notify("Event", "Added control...").Show();
        }
    
    
        protected void btCheck_Click(object sender, DirectEventArgs e)
        {
            X.Msg.Notify("Items", Panel1.Items.Count).Show();
        }
    </script>
    
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server">
        </ext:ResourceManager>
        <ext:Panel ID="Panel1" runat="server" Height="300" Title="Title" AutoScroll="true">
            <Items>
            </Items>
            <BottomBar>
                <ext:Toolbar ID="Toolbar1" runat="server">
                    <Items>
                        <ext:Button ID="btAdd" runat="server" Text="Add Composite Items" Icon="Add">
                            <DirectEvents>
                                <Click OnEvent="btAdd_Click">
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:Button ID="btCheck" runat="server" Text="How may items inside Panel1?" Icon="Help">
                            <DirectEvents>
                                <Click OnEvent="btCheck_Click" ViewStateMode="Enabled">
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
            </BottomBar>
        </ext:Panel>
        </form>
    </body>
    </html>
  2. #2

Similar Threads

  1. Replies: 1
    Last Post: May 09, 2012, 7:08 PM
  2. Replies: 10
    Last Post: Aug 01, 2011, 1:58 PM
  3. [CLOSED] get value of controls created in code-behind
    By vali1993 in forum 1.x Legacy Premium Help
    Replies: 18
    Last Post: Sep 30, 2010, 3:07 PM
  4. Replies: 6
    Last Post: Jun 18, 2010, 4:23 PM
  5. [CLOSED] [1.0] CommandColumn created runtime does not appear
    By PoloTheMonk in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 30, 2010, 5:02 PM

Posting Permissions