contentplaceholder - how to loop through form values ?

Last post 07-04-2008 1:54 AM by apalchaudhry. 3 replies.

Sort Posts:

  • contentplaceholder - how to loop through form values ?

    07-16-2006, 7:43 AM
    • Member
      345 point Member
    • Lamentations
    • Member since 06-29-2006, 2:09 AM
    • Posts 69
    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 ?


  • controls within contentplaceholder ?

    07-16-2006, 8:53 AM
    • Member
      345 point Member
    • Lamentations
    • Member since 06-29-2006, 2:09 AM
    • Posts 69
    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);
        }
    }
     
  • Re: controls within contentplaceholder ?

    07-16-2006, 9:03 AM
    • All-Star
      45,563 point All-Star
    • haidar_bilal
    • Member since 07-14-2003, 1:43 AM
    • Lebanon - Beirut
    • Posts 8,726
    • TrustedFriends-MVPs

    Have a look at:

    ASP.NET 2.0 Masterpages and FindControl

    hth,

    Regards

     

     

    Bilal Hadiar, MCP, MCTS, MCPD, MCT
    Microsoft MVP - Telerik MVP
  • Re: controls within contentplaceholder ?

    07-04-2008, 1:54 AM
    • Member
      2 point Member
    • apalchaudhry
    • Member since 07-04-2008, 1:51 AM
    • Posts 1
    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; } } }
Page 1 of 1 (4 items)