Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Using "For Each ctrl In.." Statment Inside UserControl

Reply
Thread Tools

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

 
 
crjunk
Guest
Posts: n/a
 
      09-02-2004
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
 
Reply With Quote
 
 
 
 
Karl
Guest
Posts: n/a
 
      09-02-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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



 
Reply With Quote
 
 
 
 
crjunk
Guest
Posts: n/a
 
      09-03-2004
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#(E-Mail Removed)>...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Disabling the shortcuts such as Ctrl+A, Ctrl+B.... using Javascript Gouri.Mahajan7@gmail.com ASP .Net 2 07-10-2008 08:15 AM
PIX route inside statment John Cisco 1 09-27-2005 03:06 AM
Access a control inside an usercontrol from another control inside another usercontrol nail ASP .Net 0 09-15-2004 03:55 PM
Implement Ctrl-C, Ctrl-V Danny C++ 5 08-15-2003 03:04 AM
Help with select statment on for-each Bill Sneddon XML 2 06-28-2003 01:28 AM



Advertisments