Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
For ... each control?
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00920575
Message ID:
00920589
Vues:
28
This message has been marked as the solution to the initial question of the thread.
Joe,

You first have to find the form object, then loop the controls of the form. Below is an example sub of how that can be done:
    Private Sub LoopTextBoxes()

        ' Variables
        Dim nCnt%
        Dim oType As System.Type
        Dim frmTrgt As System.Web.UI.HtmlControls.HtmlForm
        Dim txtObj As System.Web.UI.WebControls.TextBox

        ' Loop Controls - Get Form
        For nCnt = 0 To Controls.Count - 1

            ' Assign Type
            oType = Controls(nCnt).GetType

            ' Determine Match
            If InStr(UCase(oType.FullName), "HTMLFORM", CompareMethod.Text) Then

                ' Assign Value
                frmTrgt = Controls(nCnt)

                ' Bail
                Exit For

            End If

            ' Free Memory
            oType = Nothing

        Next

        ' Loop Controls - Get Form
        For nCnt = 0 To frmTrgt.Controls.Count - 1

            ' Assign Type
            oType = frmTrgt.Controls(nCnt).GetType

            ' Determine Match
            If InStr(UCase(oType.FullName), "TEXT", CompareMethod.Text) Then

                ' Assign Control
                txtObj = frmTrgt.Controls(nCnt)

                ' Assign Value
                txtObj.Text = "Got It"

                ' Free Mem
                txtObj = Nothing

            End If

            ' Free Memory
            oType = Nothing

        Next

    End Sub
Happy 4th! Hope that helps...
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform