problem iterating thru controls on a page

Discussion in 'ASP.NET / ASP.NET Core' started by nature, Apr 18, 2005.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. This code should show me all controls on the page - there are a whole bunch of textboxes and a button but they don't show up in the response.write statements.

    These are all that show up.
    System.Web.UI.LiteralControl
    System.Web.UI.HtmlControls.HtmlForm
    System.Web.UI.LiteralControl

    What do I need to do to see the rest of them?

    Thanks,
    Carl


    sub page_load()
    if ispostback then
    checkControls (page)
    end if
    end sub

    sub checkControls(s as object)
    dim ctlControl as control
    for each ctlControl in s.controls

    displayControlInfo(ctlControl)

    next
    end sub

    sub displayControlInfo(s as object)
    response.write( s.gettype().tostring() &"" )
    response.write( s.ID &"" )
    end sub
     
  2. Getting controls can be tricky, they are usually hiding at a layer that you might not think. The Visual Studio.NET debugger Quickwatch is excellent for finding the proper level. Try changing s.controls until you find the proper level or just use Quickwatch if you have VS.NET.

    The controls you want are likely chid controls of another control on the page, a panel maybe.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page