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. Finding control

Finding control

Scheduled Pinned Locked Moved ASP.NET
debugging
4 Posts 2 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.
  • T Offline
    T Offline
    TAK78
    wrote on last edited by
    #1

    I try to loop through the controls in the page and to identify certain controls, but I can't locate them. Here is my code: Protected Sub submitBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submitBtn.Click Dim errMsg As String = "" For Each ctrl As Control In Me.Controls If TypeOf ctrl Is TextBox Then errMsg &= "Found it!" Else errMsg &= "Nothing Found!" End If msgText.Text = errMsg Next End Sub When I trace the ctrl as String output I get ASP.masterpage_master

    S 1 Reply Last reply
    0
    • T TAK78

      I try to loop through the controls in the page and to identify certain controls, but I can't locate them. Here is my code: Protected Sub submitBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submitBtn.Click Dim errMsg As String = "" For Each ctrl As Control In Me.Controls If TypeOf ctrl Is TextBox Then errMsg &= "Found it!" Else errMsg &= "Nothing Found!" End If msgText.Text = errMsg Next End Sub When I trace the ctrl as String output I get ASP.masterpage_master

      S Offline
      S Offline
      Sujit Gupta
      wrote on last edited by
      #2

      Try by the Page.control

      Sujit

      T 1 Reply Last reply
      0
      • S Sujit Gupta

        Try by the Page.control

        Sujit

        T Offline
        T Offline
        TAK78
        wrote on last edited by
        #3

        Didn't work either, tried that before! (using Masterpage!!!!)

        T 1 Reply Last reply
        0
        • T TAK78

          Didn't work either, tried that before! (using Masterpage!!!!)

          T Offline
          T Offline
          TAK78
          wrote on last edited by
          #4

          Found the solution: Protected Sub submitBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submitBtn.Click Dim errMsg As String = "" Dim ctHolder As ContentPlaceHolder ctHolder = CType(Master.FindControl("ContentPlaceHolder1"), ContentPlaceHolder) For Each ctrl As Control In ctHolder.Controls If TypeOf ctrl Is TextBox Then errMsg &= "Found it!" & ctrl.ID.ToString() & "
          " End If Next msgText.Text = errMsg End Sub Thanks so for the suggestion!

          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