Ajoute cette méthode pour trouver tous les textboxes:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| private List<T> GetControlList<T>(ControlCollection controlCollection) where T : Control
{
var newlist = new List<T>();
foreach (Control control in controlCollection)
{
if (control is T) // This is cleaner
newlist.Add((T)control);
if (control.HasControls())
newlist.AddRange(GetControlList<T>(control.Controls));
}
return newlist;
} |
Modifies ce code pour tes besoins.
Console.WriteLine(String.Join(";", GetControlList<TextBox>(Page.Controls).FindAll(x => !String.IsNullOrEmpty(x.Text)).ConvertAll(x => x.Text)));
Partager