|
-
Jun 29th, 2006, 01:28 PM
#1
Thread Starter
Hyperactive Member
[2005] trying to loop through text boxes
for some reason my code won't recognize text boxes on my webform?
Code:
Dim myControl As Control
For Each myControl In Page.Controls
If myControl.GetType Is GetType(System.Web.UI.WebControls.TextBox) Then
CType(myControl, TextBox).Text = String.Empty
End If
Next myControl
-
Jun 29th, 2006, 02:00 PM
#2
Re: [2005] trying to loop through text boxes
Your boxes are probably not direct descendants of the Page object.
You need to write a recursive function that calls itself each time on all controls as it finds them, so that all controls get analyzed.
Be warned; your code is going to be slow. This is not the way to be clearing out boxes usually. Even though it means more work to you as the programmer, you should manually create an array with the Controls as each member of the array and then loop the array.
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Jul 1st, 2006, 02:11 PM
#3
Re: [2005] trying to loop through text boxes
Are you sure they're textboxes, or HTMLTEXTBOXes?
-
Jul 5th, 2006, 07:52 AM
#4
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|