I create a DIV
that runs on the server and then dynamically create and add TextBox
controls to that DIV
. Later when I try to read the Text property of each TextBox
in DIV
I cannot get the controls...
How do I accomplish this?
DIV that runs at server...
<div id="divBonusPercents" runat="server"></div>
Dynamically Add Textboxes based on some condition...
foreach (ListItem item in lbTeamsEOM.Items)
if (item.Selected)
{
// add controls for team bonus %
TextBox tbPercent = new TextBox();
tbPercent.Text = "15%";
tbPercent.ID = "tbPercent" + item.Value;
divBonusPercents.Controls.Add(tbPercent);
}
Get the value for each TextBox in the DIV
List<string> lBonusPercent = new List<string>();
foreach (Control c in divBonusPercents.Controls)
if (c.GetType() == typeof(TextBox))
lBonusPercent.Add(((TextBox)c).Text);