how to locate dynamically created controls?
-
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 -
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 diHi 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 theControls
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 theFindControl
method,Controls
collection or you can keep the control variable that you create earlier.