I'm recursing through the controls in an asp.net page to find if any TextBox
contains text.
JOOI, can I break out of the recursion as soon as it's found one, or does it
have to unwind itself?
The TextBoxes are generated at run-time.
VB.NET 2003, so no Control.FindCon trol.
Andrew 6 1662
IMO, recursion isn't the way to go. Use a For Each loop, then Exit when
you've found a (the) textbox you need.
--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
Hey Dick,
But surely you need recursion to check the child controls of each child
control and so forth. So I'd imagine it would be along the lines of:
Function GetFirstTextBox (cntl as control) as textbox
For each tbx in cntl.Controls.O fType(Of TextBox)
return tbx
Next
For each c in cntl.Controls
If GetFirstTextBox (c) Isnot Nothing then return Ctype(c,textbox )
Next
return nothing
End Function
"Dick Grier" <dick_grierNOSP AM@.msn.comwrot e in message
news:ex******** ******@TK2MSFTN GP02.phx.gbl...
IMO, recursion isn't the way to go. Use a For Each loop, then Exit when
you've found a (the) textbox you need.
--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
ooops....
"Bill McCarthy" <Bi**@NOSPAM.co mwrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
>
Function GetFirstTextBox (cntl as control) as textbox
For each tbx in cntl.Controls.O fType(Of TextBox)
return tbx
Next
For each c in cntl.Controls
Dim tbx as textbox = GetFirstTextBox (c)
If tbx Isnot Nothing then return tbx
Next
return nothing
End Function
Oh, and to answer the original question, returning out of the recursion as
above is fine. It won't require an unwinding. Each method finishes/exits
with the return statement.
Andrew,
AFAIK not really as you need to go back to the main stack in your loop to
unwind the stacks you have created while doing the recursion.
Cor
"Andrew Morton" <ak*@in-press.co.uk.inv alidschreef in bericht
news:uo******** ******@TK2MSFTN GP03.phx.gbl...
I'm recursing through the controls in an asp.net page to find if any
TextBox contains text.
JOOI, can I break out of the recursion as soon as it's found one, or does
it have to unwind itself?
The TextBoxes are generated at run-time.
VB.NET 2003, so no Control.FindCon trol.
Andrew
"Andrew Morton" <ak*@in-press.co.uk.inv alidwrote in message
news:uo******** ******@TK2MSFTN GP03.phx.gbl...
I'm recursing through the controls in an asp.net page to find if any
TextBox contains text.
JOOI, can I break out of the recursion as soon as it's found one, or does
it have to unwind itself?
Yes, it needs to 'unwind' itself. This is no big deal as it's likely to only
be 2 or 3 levels at most.
Michael
Thanks to all of you for your replies.
Andrew This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Peri |
last post by:
I'm trying to create Python parser/interpreter using ANTLR.
Reading grammar from language refference I found:
or_expr::= xor_expr | or_expr "|" xor_expr
For me it looks like infinite recursion. And so it says ANTLR. Maybe I
don't understand EBNF notation. For me it should look like this.
or_expr::= xor_expr | xor_expr "|" xor_expr
and in ANTLR grammar file like this:
|
by: da Vinci |
last post by:
Greetings.
I want to get everyone's opinion on the use of recursion.
We covered it in class tonight and I want a good solid answer from
people in the "know" on how well recursion is accepted in modern day
applications.
Should we readily use it when we can or only when absolutly forced to
use it?
|
by: Dennis M. Marks |
last post by:
I have a 3 level array. First level is a list of trains. Second level
are items about the train. Third level is where there are multiples of
the second level item.
The search will be of myArray
i is train entry, 2 is the item i'm searching and j are the individial
items.
My search will be FOR (i=0 etc , FOR (j= 0 etc.
|
by: Lorenzo Villari |
last post by:
I've tried to transform this into a not recursive version but without
luck...
#include <stdio.h>
void countdown(int p)
{
int x;
|
by: Csaba Gabor |
last post by:
I suppose spring fever has hit at alt.math.undergrad since I didn't get
any rise from
them when I posted this a week ago, so I am reposting this to some of
my favorite
programming groups:
I'm looking for problems that have double (or more) recursion, where
the split is not
clean (ie. where there may be overlap). Let's call this overlapped
recursion, where the
| |
by: Sathyaish |
last post by:
Can every problem that has an iterative solution also be expressed in
terms of a recursive solution?
I tried one example, and am in the process of trying out more examples,
increasing their complexity as I go. Here's a simple one I tried out:
#include<stdio.h>
/* To compare the the time and space cost of iteration against
|
by: MTD |
last post by:
Hello all,
I've been messing about for fun creating a trial division factorizing
function and I'm naturally interested in optimising it as much as
possible.
I've been told that iteration in python is generally more
time-efficient than recursion. Is that true?
Here is my algorithm as it stands. Any suggestions appreciated!
|
by: athar.mirchi |
last post by:
..plz define it.
|
by: Muzammil |
last post by:
int harmonic(int n) {
if (n=1) {
return 1;
}
else {
return harmonic(n-1)+1/n;
}
}
can any help me ??
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |