Nov 15, 2011, 1:44 PM
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
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>