U
utterberg
Can anyone help me with this problem?
I dynamically creates several textboxes using a placeholder. This works
fine. But is there a way for me to loop through theese textboxes and
retrive its value when clicking a button?
The code I'm working with:
aspx-page
<form id="Form1" method="post" runat="server">
<asplaceHolder ID="EDCTextBoxes" Runat="server" />
<asp:button ID="btnSave" Runat="server" />
</form>
code behind
private void DCP_Init(object sender, EventArgs e) {
CreateTextBoxes();
}
private void CreateTextBoxes(){
this.EDCTextBoxes.Controls.Add(new TextBox());
IterateThroughChildren(this);
}
private void IterateThroughChildren(Control parent){
foreach (Control c in parent.Controls){
if(c.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox")
&& c.ID == null){
((TextBox) c).CssClass = "txtCountryIncrease";
((TextBox) c).ID = UniqueID;
}
if (c.Controls.Count > 0){
IterateThroughChildren(c);
}
}
}
private void btnSave_Click(object sender, EventArgs e){
}
I'm a bit of a newbe at this so please explain to me like you would a
two year old infant
Thanks in advance!
I dynamically creates several textboxes using a placeholder. This works
fine. But is there a way for me to loop through theese textboxes and
retrive its value when clicking a button?
The code I'm working with:
aspx-page
<form id="Form1" method="post" runat="server">
<asplaceHolder ID="EDCTextBoxes" Runat="server" />
<asp:button ID="btnSave" Runat="server" />
</form>
code behind
private void DCP_Init(object sender, EventArgs e) {
CreateTextBoxes();
}
private void CreateTextBoxes(){
this.EDCTextBoxes.Controls.Add(new TextBox());
IterateThroughChildren(this);
}
private void IterateThroughChildren(Control parent){
foreach (Control c in parent.Controls){
if(c.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox")
&& c.ID == null){
((TextBox) c).CssClass = "txtCountryIncrease";
((TextBox) c).ID = UniqueID;
}
if (c.Controls.Count > 0){
IterateThroughChildren(c);
}
}
}
private void btnSave_Click(object sender, EventArgs e){
}
I'm a bit of a newbe at this so please explain to me like you would a
two year old infant
Thanks in advance!