Re: Iterating controls gives stackoverflow
From: Bill Borg (BillBorg_at_discussions.microsoft.com)
Date: 09/09/04
- Next message: Scott Allen: "Re: Sharing HttpCache Across AppDomains?"
- Previous message: Peter Afonin: "Re: System.UnauthorizedAccessException"
- In reply to: Karl: "Re: Iterating controls gives stackoverflow"
- Next in thread: Kevin Spencer: "Re: Iterating controls gives stackoverflow"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 9 Sep 2004 10:43:02 -0700
Too bad intellisense can't always save me from myself...thanks much for the
fast reply.
Bill
"Karl" wrote:
> You are looping over Me.Controls over and over again, you want to do:
>
> For each ctl as Control in CC
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "Bill Borg" <BillBorg@discussions.microsoft.com> wrote in message
> news:F109BBEE-1E5C-4B07-9E2D-871A7E233AED@microsoft.com...
> > Hello all,
> >
> > Below is the code (vb) for a routine that's meant to loop through a
> > collection of controls, find the textboxes, and trim the whitespace (sub
> > TrimText not shown). I expect to pass it a page, and have it iterate
> through
> > the controls on that page, and on any user controls, etc. What happens is
> > that the first time TrimAllFields is called from within the function, I
> get a
> > stackoverflow. Am I missing something simple here? Or, is there an easier
> way
> > to trim whitespace from controls?
> >
> > Thanks,
> >
> > Bill Borg
> >
> > ' ------------------------------------------
> > ' Class: TSPage
> > ' Method: TrimAllFields(CC as ControlCollection)
> > ' Description: Trim whitespace from all controls in the collection.
> > ' This routine is meant to be run recursively to iterate
> > ' all controls in the collection.
> > ' ------------------------------------------
> > Public Sub TrimAllFields(ByVal CC As ControlCollection)
> >
> > For Each ctl As Control In Me.Controls
> > ' Trim the textbox
> > If TypeOf (ctl) Is TextBox Then
> > TrimText(CType(ctl, TextBox))
> > End If
> >
> > ' Need to go deeper?
> > If ctl.HasControls Then
> > TrimAllFields(ctl.Controls)
> > End If
> > Next
> > End Sub
> >
>
>
>
- Next message: Scott Allen: "Re: Sharing HttpCache Across AppDomains?"
- Previous message: Peter Afonin: "Re: System.UnauthorizedAccessException"
- In reply to: Karl: "Re: Iterating controls gives stackoverflow"
- Next in thread: Kevin Spencer: "Re: Iterating controls gives stackoverflow"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|