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. how to locate dynamically created controls?

how to locate dynamically created controls?

Scheduled Pinned Locked Moved ASP.NET
helphtmlsysadmintutorialquestion
2 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
    Texas_CodeMaster
    wrote on last edited by
    #1

    How to locate a dynamically created control? help! hello, i need help finding MY dynamically created html file field controls... i have looped and looped until my brain can no longer loop. Since they are dynamically created i will need assistance with this because i have not yet dealt with this... i have read alot of articals on the net however no one really gets into the file fields... can someone please help with this? ===================================================== Where the controls are made... == Me.lblMakeFileInput.Text += "" Me.lblMakeFileInput.Text += " " & " " Me.lblMakeFileInput.Text += "" Me.lblMakeFileInput.Text += "" & sdI.Name.ToString & "" & " " ===================================================== how i am trying to loop === Dim s As String Dim c As Control For Each c In Me.Controls If TypeOf c Is HtmlControl Then End If Next End Sub End Class Create the controls... ===================================================== Private Sub Create_Directories() Dim oFile As System.IO.File Dim sR As System.IO.StreamReader Dim WarService As String = Nothing sR = oFile.OpenText(Server.MapPath("~/Bid_War/War_Services/War_Services.txt")) 'Specify the directories you want to manipulate. Dim path As String = Nothing Try 'Create the directories first so when the user desides to upload their War Items the directorys to choose 'from will have already been processed and ready to access Do WarService = Nothing WarService = sR.ReadLine() path = Server.MapPath("~/Bid_War/DirectoryMain_War") & "\" & Session("Email").ToString & "\" & Session("LName").ToString & "\" & "Sent_Files" & "\" & WarService If Directory.Exists(path) = False Then ' Create the directory. Directory.CreateDirectory(path) End If Loop Until WarService Is Nothing sR.Close() Catch e As Exception Session("TravelNotes") = "There was an error while trying to create your new Bid War folders." End Try '" " & "
    " Try 'Find path to where our Directories are at and retrieve all the directories under the sent items Dim di

    M 1 Reply Last reply
    0
    • T Texas_CodeMaster

      How to locate a dynamically created control? help! hello, i need help finding MY dynamically created html file field controls... i have looped and looped until my brain can no longer loop. Since they are dynamically created i will need assistance with this because i have not yet dealt with this... i have read alot of articals on the net however no one really gets into the file fields... can someone please help with this? ===================================================== Where the controls are made... == Me.lblMakeFileInput.Text += "" Me.lblMakeFileInput.Text += " " & " " Me.lblMakeFileInput.Text += "" Me.lblMakeFileInput.Text += "" & sdI.Name.ToString & "" & " " ===================================================== how i am trying to loop === Dim s As String Dim c As Control For Each c In Me.Controls If TypeOf c Is HtmlControl Then End If Next End Sub End Class Create the controls... ===================================================== Private Sub Create_Directories() Dim oFile As System.IO.File Dim sR As System.IO.StreamReader Dim WarService As String = Nothing sR = oFile.OpenText(Server.MapPath("~/Bid_War/War_Services/War_Services.txt")) 'Specify the directories you want to manipulate. Dim path As String = Nothing Try 'Create the directories first so when the user desides to upload their War Items the directorys to choose 'from will have already been processed and ready to access Do WarService = Nothing WarService = sR.ReadLine() path = Server.MapPath("~/Bid_War/DirectoryMain_War") & "\" & Session("Email").ToString & "\" & Session("LName").ToString & "\" & "Sent_Files" & "\" & WarService If Directory.Exists(path) = False Then ' Create the directory. Directory.CreateDirectory(path) End If Loop Until WarService Is Nothing sR.Close() Catch e As Exception Session("TravelNotes") = "There was an error while trying to create your new Bid War folders." End Try '" " & "
      " Try 'Find path to where our Directories are at and retrieve all the directories under the sent items Dim di

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, In fact, you are not dynamically adding the html input file control to the web page. What you are doing is to simply assign the ASP.NET markup (string) to the Text property of a Label control ( i guess so via the name lblMakeFileInput). So there is no input file control in the control hierarchy, so you cannot find it. If you want to dynamically create the control, you need to initialize the control with the new keyword as you would with a normal object, then add it to the Controls collection of a container like the Form, Panel, PlaceControlHolder ....Once you add it to the control hierarchy of the web page, you can find it using the FindControl method, Controls collection or you can keep the control variable that you create earlier.

      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