Hello,
I have a recursive method that looks through an ASP.Net page to find a
control by ID. My problem is after it finds the control, breaks from the
loop and returns the control, it goes to my recursive line (if
control.HasControls call the findctl method). I think the problem lies in
that the method returns a value. Is this the case? Any ideas?
Thanks
private Control FindCtl(Control oControl, string controlID)
{
Control control = new Control();
foreach (Control ctl in oControl.Controls)
{
if (ctl.ID == controlID)
{
control = ctl;
break;
}
if (ctl.HasControls())
{
FindCtl(ctl, controlName);
}
}
return control;
} 5 1107
Hi
Does the method findcontrol not do what you want?
Mark
Hello,
I have a recursive method that looks through an ASP.Net page to find a
control by ID. My problem is after it finds the control, breaks from the
loop and returns the control, it goes to my recursive line (if
control.HasControls call the findctl method). I think the problem lies in
that the method returns a value. Is this the case? Any ideas?
Thanks
private Control FindCtl(Control oControl, string controlID)
{
Control control = new Control();
foreach (Control ctl in oControl.Controls)
{
if (ctl.ID == controlID)
{
control = ctl;
break;
}
if (ctl.HasControls())
{
FindCtl(ctl, controlName);
}
}
return control;
}
Mark,
It finds the control however after it breaks out of the loop and then hits
return control line it goes up to FindCtl(ctl, controlName); line. I do not
know why this is happening?
Thanks
"mark carew" <ma*******@magicwanddept.com.auwrote in message
news:7p****************************@40tude.net...
Hi
Does the method findcontrol not do what you want?
Mark
>Hello,
I have a recursive method that looks through an ASP.Net page to find a control by ID. My problem is after it finds the control, breaks from the loop and returns the control, it goes to my recursive line (if control.HasControls call the findctl method). I think the problem lies in that the method returns a value. Is this the case? Any ideas?
Thanks
private Control FindCtl(Control oControl, string controlID) { Control control = new Control(); foreach (Control ctl in oControl.Controls) {
if (ctl.ID == controlID) { control = ctl; break; }
if (ctl.HasControls()) { FindCtl(ctl, controlName); } } return control; }
I would change it to something like:
if (ctl.HasControls())
{
control = FindCtl(ctl, controlName);
if (control != null)
break;
}
"Mike" <mi***@mike.comwrote in message
news:%2***************@TK2MSFTNGP02.phx.gbl...
Hello,
I have a recursive method that looks through an ASP.Net page to find a
control by ID. My problem is after it finds the control, breaks from the
loop and returns the control, it goes to my recursive line (if
control.HasControls call the findctl method). I think the problem lies in
that the method returns a value. Is this the case? Any ideas?
Thanks
private Control FindCtl(Control oControl, string controlID)
{
Control control = new Control();
foreach (Control ctl in oControl.Controls)
{
if (ctl.ID == controlID)
{
control = ctl;
break;
}
if (ctl.HasControls())
{
FindCtl(ctl, controlName);
}
}
return control;
}
Thanks for the post. I changed my method to this:
public Control FindCtl(Control oControl, string controlID)
{
if (oControl.controlID == Id) return oControl;
foreach (Control Ctl in oControl.Controls)
{
Control FoundCtl = FindCtl(Ctl, controlID);
if (FoundCtl != null)
return FoundCtl;
}
return null;
}
"Marina Levit [MVP]" <so*****@nospam.comwrote in message
news:OS**************@TK2MSFTNGP02.phx.gbl...
>I would change it to something like:
if (ctl.HasControls())
{
control = FindCtl(ctl, controlName);
if (control != null)
break;
}
"Mike" <mi***@mike.comwrote in message
news:%2***************@TK2MSFTNGP02.phx.gbl...
>Hello,
I have a recursive method that looks through an ASP.Net page to find a control by ID. My problem is after it finds the control, breaks from the loop and returns the control, it goes to my recursive line (if control.HasControls call the findctl method). I think the problem lies in that the method returns a value. Is this the case? Any ideas?
Thanks
private Control FindCtl(Control oControl, string controlID) { Control control = new Control(); foreach (Control ctl in oControl.Controls) {
if (ctl.ID == controlID) { control = ctl; break; }
if (ctl.HasControls()) { FindCtl(ctl, controlName); } } return control; }
On 14 Dez., 20:24, "Mike" <m...@mike.comwrote:
Hello,
I have a recursive method that looks through an ASP.Net page to find a
control by ID. My problem is after it finds the control, breaks from the
loop and returns the control, it goes to my recursive line (if
control.HasControls call the findctl method). I think the problem lies in
that the method returns a value. Is this the case? Any ideas?
Thanks
private Control FindCtl(Control oControl, string controlID)
{
Control control = new Control();
foreach (Control ctl in oControl.Controls)
{
if (ctl.ID == controlID)
{
control = ctl;
break;
}if (ctl.HasControls())
{
FindCtl(ctl, controlName);
}
}
return control;
}
Hi,
try this(in VB.NET):
Private Function FindCtl(ByVal id As String, ByVal ctl As Control) As
Control
For Each cControl As Control In ctl.Controls
If cControl.ID.Equals(id) Then
Return cControl
End If
'looking for subcontrols
If cControl.HasControls Then
Dim ctrl As Control = FindCtl(id, cControl)
If cControl.ID.Equals(id) Then
Return cControl
End If
End If
Next
End Function This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Christian Hubinger |
last post by:
Hi!
I've implemented some DropDown list in ASP.NET that use Ajax to fetch
the data from the server. The javascript is written to call cascading to
the bottom most dropdown in order to update...
|
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: 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...
|
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...
|
by: robert |
last post by:
My code does recursion loops through a couple of functions. Due to problematic I/O input this leads sometimes to "endless" recursions and after expensive I/O to the Python recursion exception.
What...
|
by: NOO Recursion |
last post by:
Hi everyone! I am trying to write a program that will search a 12x12 for a
thing called a "blob". A blob in the grid is made up of asterisks. A blob
contains at least one asterisk. If an...
|
by: Mumia W. |
last post by:
Hello all.
I have a C++ program that can count the YOYOs that are in a grid of
Y's and O's. For example, this
Y O Y O O Y
O Y O Y O O
Y O Y Y O Y
O Y O O Y O
O Y Y O Y O
|
by: proctor |
last post by:
hello,
i have a small function which mimics binary counting. it runs fine as
long as the input is not too long, but if i give it input longer than
8 characters it gives
RuntimeError: maximum...
|
by: Jeff Bigham |
last post by:
So, it appears that Javascript has a recursion limit of about 1000
levels on FF, maybe less/more on other browsers.
Should such deep recursion then generally be avoided in Javascript?...
|
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: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
| |