Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting reference to Nested Controls
Message
De
22/06/2016 10:42:09
 
 
À
22/06/2016 09:56:38
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:
01637570
Vues:
50
>>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
>
Thanks,

I got a response from the DevExpress people. I needed to use a special method on their controls like this:
                    LayoutItem liFirstName = editForm.FindItemOrGroupByName("liFirstName") as LayoutItem;
                    ASPxTextBox txtFirstName = (ASPxTextBox)liFirstName.GetNestedControl();
                    txtFirstName.Text = firstName;
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform