Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Controls Collection

Controls Collection

Scheduled Pinned Locked Moved ASP.NET
questioncsharpasp-netlearning
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hyland Computer Systems
    wrote on last edited by
    #1

    Dear sirs: I have an ASP.NET Web Form that uses a Master Page. On it, are several Web Controls (i.e. text-boxes, GridViews, etc.) When I use a simple code-snippet like the following: foreach (Control ctl in this.Controls) { Response.Write(ctl.ID); } ... there is one control listed with an ID of "null..." However, I can, of course get the name of any control on the page with "this." How can I iterate through the controls collection of this Web Form? Thanks, R. Hyland

    L D 2 Replies Last reply
    0
    • H Hyland Computer Systems

      Dear sirs: I have an ASP.NET Web Form that uses a Master Page. On it, are several Web Controls (i.e. text-boxes, GridViews, etc.) When I use a simple code-snippet like the following: foreach (Control ctl in this.Controls) { Response.Write(ctl.ID); } ... there is one control listed with an ID of "null..." However, I can, of course get the name of any control on the page with "this." How can I iterate through the controls collection of this Web Form? Thanks, R. Hyland

      L Offline
      L Offline
      leckey 0
      wrote on last edited by
      #2

      Do you know which control it is that is coming back as null? If so, what is it's actual name?

      _____________________________________________ Flea Market! It's just like...it's just like...A MINI-MALL!

      1 Reply Last reply
      0
      • H Hyland Computer Systems

        Dear sirs: I have an ASP.NET Web Form that uses a Master Page. On it, are several Web Controls (i.e. text-boxes, GridViews, etc.) When I use a simple code-snippet like the following: foreach (Control ctl in this.Controls) { Response.Write(ctl.ID); } ... there is one control listed with an ID of "null..." However, I can, of course get the name of any control on the page with "this." How can I iterate through the controls collection of this Web Form? Thanks, R. Hyland

        D Offline
        D Offline
        Dr_X
        wrote on last edited by
        #3

        Use the following code to obtain the control containing all of your forms controls. Me.FindControl("ctl00").FindControl("contentMaster")) where "contentMaster" is referenced from your asp:content control located at the top of your aspx's source view page. < ... form's html ... Now you have a reference to the control containing all of the controls residing on the page. Michael

        I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970)

        H 1 Reply Last reply
        0
        • D Dr_X

          Use the following code to obtain the control containing all of your forms controls. Me.FindControl("ctl00").FindControl("contentMaster")) where "contentMaster" is referenced from your asp:content control located at the top of your aspx's source view page. < ... form's html ... Now you have a reference to the control containing all of the controls residing on the page. Michael

          I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970)

          H Offline
          H Offline
          Hyland Computer Systems
          wrote on last edited by
          #4

          Thank you so much, your answer was spot-on! R. H.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups