在我的应用程序中,我有一个母版页、一个使用母版页的网页、一个面板,在面板控件中,我有几个文本框控件和一个用于触发回发的按钮。我编写了以下代码来读取文本框中输入的值。但是,文本框的计数为 0。您能否让我知道代码中有什么问题:
// Function to read the entries of the text boxes.
public ArrayList GetAllTextBoxes(Control parent)
{
ArrayList myActions = new ArrayList();
foreach (Control c in parent.Controls)
{
// Check and see if it's a textbox
if ((c.GetType() == typeof(TextBox)))
{
// Since its a textbox read the text
myActions.Add(((TextBox)(c)).Text);
}
// Now we need to call itself (recursion)
if (c.HasControls())
{
GetAllTextBoxes(c);
}
}
return myActions;
}
and this function is called like this on the click button function:
protected void Button1_Click(object sender, EventArgs e)
{
ArrayList allActions = new ArrayList();
ManageDef setStatus = new ManageDef();
allActions = setStatus.GetAllTextBoxes(this);
}