Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Fastest way to scan for textbox controls
Message
De
11/12/2012 08:41:43
 
 
À
11/12/2012 08:13:18
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01559234
Message ID:
01559286
Vues:
61
This message has been marked as a message which has helped to the initial question of the thread.
>>if (loControl is TextBox) instead of string conversion. It'll be faster than a string type comparison.
>
>Is this a C# only syntax BTW?

try
                   If TypeOf loControl Is System.Web.UI.WebControls.TextBox Then
>This is the updated code:
>
>
>                ' For each control in this form
>                For Each loControl In loHtmlForm.Controls
>
>                    ' If this is a textbox
>                    If  loControl Is System.Web.UI.WebControls.TextBox Then
>
>                        ' Assign this control to a textbox variable
>                        loTextbox = loControl
>
>                        ' Add the onkeypress to the textbox
>                        loTextbox.Attributes.Add("onkeypress", "FormKeyPress(event)")
>
>                    End If
>
>                Next
>
>
>This gives: "'TextBox' is a type in 'WebControls' and cannot be used as an expression."
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform