473,508 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ControlCollection in ASPX page

Hi,
I need from ControlCollection on aspx page select all TextBoxes.
How can I do it?

Thanks
Nov 16 '05 #1
4 2334
Hi,

One thing you can do is iterate in the Page.Controls checking for the
control's type and storing them in an array
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Luboš Šlapák" <lu**********@centrum.cz> wrote in message
news:Oz**************@tk2msftngp13.phx.gbl...
Hi,
I need from ControlCollection on aspx page select all TextBoxes.
How can I do it?

Thanks

Nov 16 '05 #2
I don't know how to check it for control's type.
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> píše v
diskusním příspěvku news:Ov**************@TK2MSFTNGP15.phx.gbl...
Hi,

One thing you can do is iterate in the Page.Controls checking for the
control's type and storing them in an array
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Luboš Šlapák" <lu**********@centrum.cz> wrote in message
news:Oz**************@tk2msftngp13.phx.gbl...
Hi,
I need from ControlCollection on aspx page select all TextBoxes.
How can I do it?

Thanks


Nov 16 '05 #3

"Luboš Šlapák" <lu**********@centrum.cz> wrote in message news:Oz**************@tk2msftngp13.phx.gbl...
Hi,
I need from ControlCollection on aspx page select all TextBoxes.
How can I do it?

Thanks


foreach (Control ctrl in this.Controls)
{
TextBox tb = ctrl as TextBox;
if (tb != null)
{
// do something with TextBox tb ...
}
}
Note: do NOT try this:
foreach (TextBox tb in this.Controls) { ... }
This does not *filter* for textboxes, but tries to cast *all* controls to textboxes,
which will fail.

Hans Kesting
Nov 16 '05 #4
Hi,

try this:
ArrayList textboxArray = new ArrayList();
foreach(Control control in this.Controls)
if ( control.GetType() == typeof( TextBox) )
textboxArray.Add( control );
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Luboš Šlapák" <lu**********@centrum.cz> wrote in message
news:ud**************@TK2MSFTNGP15.phx.gbl...
I don't know how to check it for control's type.
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> píše v diskusním příspěvku news:Ov**************@TK2MSFTNGP15.phx.gbl...
Hi,

One thing you can do is iterate in the Page.Controls checking for the
control's type and storing them in an array
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Luboš Šlapák" <lu**********@centrum.cz> wrote in message
news:Oz**************@tk2msftngp13.phx.gbl...
Hi,
I need from ControlCollection on aspx page select all TextBoxes.
How can I do it?

Thanks



Nov 16 '05 #5

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

Similar topics

0
1525
by: Trevor Germain | last post by:
Scenario: --------- I have an Explorer style application. The app hosts other win forms by making them MDI children, removing border / control box / minimize / maximize, and setting the form's...
1
5625
by: K | last post by:
Can anyone tell me why VB can successfully inherit from the ControlCollection class but C# can't? When compiling the following 2 classes, the C# version gets a compile error of: "No overload...
1
1847
by: mccoyn | last post by:
I am having trouble adding a control to ControlCollection in a class I have derived from GroupBox. Here is what I've got __gc class RowColumn : public System::Windows::Forms::GroupBo public...
0
1748
by: Harry F. Harrison | last post by:
Here's the situation...Context - Using an Inherited WebControl object as a base for server custom controls. In a web custom control, whenever I create a child control and add it to the Controls...
1
1662
by: DanielSchaffer | last post by:
I am trying to create a class that inherits fromControlCollection, but I am getting the compile error "Nooverload for method 'ControlCollection' takes '0' arguments",and VS highlights the constructor...
3
2325
by: Phill. W | last post by:
Is it possible to extend the Windows.Forms.Form.ControlCollection class and override it's Add method? I'm adding controls to a Form and want to hook up Event Handling for the Form to deal with...
3
4036
by: Steve | last post by:
I have a number of controls within a Panel. If I do For Each ctrl In PanelMain.Controls MsgBox(ctrl.Name) Next The controls are not displayed in the sequence I would expect them to be (top...
0
2198
by: Gursharan | last post by:
Hi, I get this error after I did a load test on my website (500 constant user load in team system for 35 minutes). This error is logged after about 1 minute of load testing and is logged every...
1
1213
by: rn5a | last post by:
An ASP.NET Form has different server controls like Panels, Labels, TextBoxes, HiddenFields etc. The Form has a DataList as well. This is how the DataList looks: <form runat="server">...
0
7226
marktang
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,...
0
7328
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
7388
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...
1
7049
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
7499
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5631
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,...
0
4709
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3199
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...
0
1561
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 ...

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.