Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting reference to Nested Controls
Message
De
22/06/2016 09:56:38
 
 
À
22/06/2016 08:43:46
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 4.0
Application:
Web
Divers
Thread ID:
01637559
Message ID:
01637565
Vues:
61
>I've created an ASP.NET form like this (this is using DevExpress controls but hopefully the logic will be the same in plain vanilla ASP.Net)

Could it be possible that specific control has children? I use something like this to get recursive on those ones:
    ' Add the onkeypress event to a textbox control
    ' expO1 Control
    Public Function FindControlRecursiveTextboxOnKeyPress(ByVal toControl As Object) As Boolean
        Dim loControl As System.Web.UI.Control = New System.Web.UI.Control
        Dim loTextbox As System.Web.UI.WebControls.TextBox = New System.Web.UI.WebControls.TextBox

        ' For each control in this form
        For Each loControl In toControl.Controls

            ' If we have controls
            If loControl.HasControls Then
                FindControlRecursiveTextboxOnKeyPress(loControl)
            End If

            ' If this is a textbox
            If TypeOf loControl Is System.Web.UI.WebControls.TextBox Then

                ' Assign this control to a textbox variable
                loTextbox = loControl

                ' If this is a regular texbox
                If loTextbox.TextMode = System.Web.UI.WebControls.TextBoxMode.SingleLine Or _
                 loTextbox.TextMode = System.Web.UI.WebControls.TextBoxMode.Password Then

                    ' If this is not read only
                    If Not loTextbox.ReadOnly Then

                        ' If this is enabled
                        If loTextbox.Enabled Then

				' If this is not a pick list
				If oApp.At("LXFrameworkLabel", loTextbox.ID) = 0 Then

					' Add the onkeypress to the textbox
					loTextbox.Attributes.Add("onkeypress", "FormKeyPress(event)")

				End If

			End If

                    End If

                End If

            End If

        Next

        Return True
    End Function
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform