473,396 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using "For Each ctrl In.." Statment Inside UserControl

I have a droped a UserControl named "ReceivedRecord1" onto my web
form. Currently, I have been saving information typed in by the user
with the following code that is located in the CodeBehind page of my
Web Form.

For Each ctrl In Page.FindControl("ReceivedRecord1").Controls
If TypeOf (ctrl) Is TextBox Then
' yada yada yada
End If
Next

I have now moved this code from my web from the CodeBehind page to the
UserControl CodeBehind page. Once I moved the code over to the
UserControl, I changed the for statement to the following:

For Each ctrl In Me.Controls
If TypeOf (ctrl) Is TextBox Then
' yada yada yada
End If
Next

This new code seems to not be able to find the TextBoxes that are on
the UserControl. What do I need to replace the "Me.Controls" with in
order for the code to find TextBoxes inside the UserControl?

Thanks!
crjunk
Nov 18 '05 #1
2 1843
There's nothing wrong with what you've shown us. Are these textboxes being
added dynamically? Can you provide more sample code of what you're aspx
page looks for the page and the usercontrol (along with any relevant
codebehind)?

Karl

"crjunk" <cr****@earthlink.net> wrote in message
news:e4**************************@posting.google.c om...
I have a droped a UserControl named "ReceivedRecord1" onto my web
form. Currently, I have been saving information typed in by the user
with the following code that is located in the CodeBehind page of my
Web Form.

For Each ctrl In Page.FindControl("ReceivedRecord1").Controls
If TypeOf (ctrl) Is TextBox Then
' yada yada yada
End If
Next

I have now moved this code from my web from the CodeBehind page to the
UserControl CodeBehind page. Once I moved the code over to the
UserControl, I changed the for statement to the following:

For Each ctrl In Me.Controls
If TypeOf (ctrl) Is TextBox Then
' yada yada yada
End If
Next

This new code seems to not be able to find the TextBoxes that are on
the UserControl. What do I need to replace the "Me.Controls" with in
order for the code to find TextBoxes inside the UserControl?

Thanks!
crjunk

Nov 18 '05 #2
Hi Karl,

It finally started working. I didn't change any of the code. I'm not
exactly sure what happened to it but it is working now.

Thanks,
Crjunk
"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:<u#*************@TK2MSFTNGP09.phx.gbl>...
There's nothing wrong with what you've shown us. Are these textboxes being
added dynamically? Can you provide more sample code of what you're aspx
page looks for the page and the usercontrol (along with any relevant
codebehind)?

Karl

"crjunk" <cr****@earthlink.net> wrote in message
news:e4**************************@posting.google.c om...
I have a droped a UserControl named "ReceivedRecord1" onto my web
form. Currently, I have been saving information typed in by the user
with the following code that is located in the CodeBehind page of my
Web Form.

For Each ctrl In Page.FindControl("ReceivedRecord1").Controls
If TypeOf (ctrl) Is TextBox Then
' yada yada yada
End If
Next

I have now moved this code from my web from the CodeBehind page to the
UserControl CodeBehind page. Once I moved the code over to the
UserControl, I changed the for statement to the following:

For Each ctrl In Me.Controls
If TypeOf (ctrl) Is TextBox Then
' yada yada yada
End If
Next

This new code seems to not be able to find the TextBoxes that are on
the UserControl. What do I need to replace the "Me.Controls" with in
order for the code to find TextBoxes inside the UserControl?

Thanks!
crjunk

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Digital Fart | last post by:
I was looking at the GFAX - Gnome fax application and i see that in the main.cs the author puts the using inside his namespace. namespace gfax { using System; using System.IO; using...
1
by: Augustin Prasanna. J | last post by:
Hi, When the user opens a new browser instance using 'Ctrl-N' and logs in with a different user login, both the browser instances begins to share the same session. Any suggestions on how to handle...
1
by: Vikas | last post by:
Hi, I am facing a very typical problem. I have a wizard like application, where user enters information by moving back & forth between the pages. At the end of wizard the data is submitted...
2
by: hemashiki | last post by:
hi i want to select multiple choices in listbox using ctrl key can any one suggest....plz
4
by: GeekBoy | last post by:
I am reading a file of numbers using for loops. The numbers are in a grid as follows: 8 36 14 11 31 17 22 23 17 8 9 33 23 32 18 39 23 25 9 38 14 38 4 22 18 11 31 19 16 17 9 32 25 8 1 23
0
by: HARISHAHI | last post by:
How to find first 3 and least rows of a table using row id( using for loop)?
1
by: Shailja | last post by:
Hi, How to increament a variable by 2 using For loop in VB 6.0. Kindly let me know if u know. Thanks
11
by: balaraja | last post by:
Hi how to print the diagonal elements of a two dimensional array using for loop Can any one help me...Plzzzzzzzz.. Thanks in advance Bala...
9
by: thelner | last post by:
Hi, quick question. I have numbered labels and i want to fill the text using for next. txt1 txt2 . . . .
6
by: gsuns82 | last post by:
Hi all, Is it possible to read the input value given by the user by ctrl+v,how do we use java script to read the input? example: If the user selects a value using ctrl+c from some where...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.