locked
contentplaceholder - how to loop through form values ? RRS feed

  • Question

  • User-348500580 posted
    If I have a bunch of input fields (textboxes, checkboxes and textarea) within a contentplaceholder, how do i loop through all the controls within this contentplaceholder, or the whole page ?


    Sunday, July 16, 2006 7:43 AM

All replies

  • User-348500580 posted
    If im using master pages with contentplaceholders, how do i get a reference to the controls within the form ?  The following code doesnt work

     
    foreach (Control c in this.Controls)
    {
        if (c is TextBox)
        {
           Response.write(((TextBox)c).text);
        }
    }
     
    Sunday, July 16, 2006 8:53 AM
  • User-1069184416 posted

    Have a look at:

    ASP.NET 2.0 Masterpages and FindControl

    hth,

    Regards

     

     

    Sunday, July 16, 2006 9:03 AM
  • User171003165 posted
    public static void ClearFormRecursive(Control Root) { foreach (Control c in Root.Controls) { if (Root is ContentPlaceHolder) { if (c is TextBox) { Response.write(((TextBox)c).text); } } else { ClearFormRecursive(c); } if (Root == null) { return; } } }
    Friday, July 4, 2008 1:54 AM