473,386 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Looping through controls

How can I loop through controls on a form and find out what type they are.
I want to loop through controls on a webform and if they are visible
textboxes change there value if NULL to "na".

Also

If I placed this code in a module or class how would the code know which
page I was refering to.
Nov 20 '05 #1
4 1772
"Poppy" <pa**********@NOSPAMthemedialounge.com> wrote in message
news:ua**************@TK2MSFTNGP11.phx.gbl...
How can I loop through controls on a form and find out what type they are.
I want to loop through controls on a webform and if they are visible
textboxes change there value if NULL to "na".
Also
If I placed this code in a module or class how would the code know which
page I was refering to.


This is a VB Lanugage group, not WebForms/ASP. In VB, you could do it like
this:

Dim c as Windows.Forms.Control
For Each c In Me.Controls
If TypeOf c Is TextBox Then
'// Do something
End If
Next
But I'm sure that doesn't help you much, I would try asking your question in
the ASP.NET group:

microsoft.public.dotnet.framework.aspnet
HTH,
Jeremy

Nov 20 '05 #2
Cheers
"Jeremy Cowles" <jeremy.cowles[nosp@m]asifl.com> wrote in message
news:92*******************@twister.tampabay.rr.com ...
"Poppy" <pa**********@NOSPAMthemedialounge.com> wrote in message
news:ua**************@TK2MSFTNGP11.phx.gbl...
How can I loop through controls on a form and find out what type they are. I want to loop through controls on a webform and if they are visible
textboxes change there value if NULL to "na".
Also
If I placed this code in a module or class how would the code know which
page I was refering to.
This is a VB Lanugage group, not WebForms/ASP. In VB, you could do it like
this:

Dim c as Windows.Forms.Control
For Each c In Me.Controls
If TypeOf c Is TextBox Then
'// Do something
End If
Next
But I'm sure that doesn't help you much, I would try asking your question

in the ASP.NET group:

microsoft.public.dotnet.framework.aspnet
HTH,
Jeremy

Nov 20 '05 #3
Cor
Hi Poppy,

I wish the "typeof" did work on a webform, but as far as I know it does
not.
That makes it almost impossible to use a for each loop with sence on a
webform.
\\\
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim ctr As Control
For Each ctr In Me.Controls
If TypeOf ctr Is TextBox Then
ctr.Visible = False
End If
Next
End Sub
///
Does nothing .
\\\
Dim ctr As Control
For Each ctr In Me.Controls
ctr.Visible = False
next
///
This works but I never could come at the text property therefore I need a
cast to textbox.

(There is no error message, you can only see it by trying this, both code is
full accepted)

Very much
;-((((
Cor
Nov 20 '05 #4
* "Poppy" <pa**********@NOSPAMthemedialounge.com> scripsit:
How can I loop through controls on a form and find out what type they are.


For Windows Forms:

<http://www.mvps.org/dotnet/dotnet/samples/controls/downloads/EnumerateControls.zip>

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #5

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

Similar topics

2
by: Ivo | last post by:
Hi, I have an audio file (.mid or .wav or .mp3) in an object element: <object id="snd" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"...
1
by: Jozef | last post by:
Hello, I'm trying to loop through forms by doing a "For Each" in the Currentdb. I'm doing this like the following; Dim db as dao.database Dim docLoop as document Dim ctrl as control Set db...
16
by: TD | last post by:
This is the code under a command button - Dim ctl As Control For Each ctl In Me.Controls If ctl.BackColor <> RGB(255, 255, 255) Then ctl.BackColor = RGB(255, 255, 255) End If Next ctl
2
by: Shawn | last post by:
Hi. I'm trying to loop through all webcontrols in my System.Web.UI.HtmlControls.HtmlForm. This is my code: Dim form As HtmlForm Dim control As Control form = Me.FindControl("completion")...
5
by: Craig G | last post by:
how do i go about this thru serverside code (VB.NET)? any links to any articles anywhere? basically i just want something simple that will loop thru all txt & cbo server side controls, and then...
5
by: johnb41 | last post by:
I need to loop through a bunch of textbox controls on my form. The order of the loop is very important. For example, the top one must be read first, then the one below it, etc. My first...
7
by: Ken | last post by:
Hi All - I have a filtered GridView. This GridView has a check box in the first column. This check box is used to identify specific rows for delete operations. On the button click event I...
6
by: jobs | last post by:
This code was working, but then stopped working. I don't think I completely understand it. I pass it a formview name and it would loop through checking the value of textboxes. problem is...
0
by: Rene Goris | last post by:
Hi all, I am trying to add meta:resourcekey's to database programmatically looping throug webcontrols, but i cann't read the 'meta:resourcekey' from the webcontrol. The 'meta:resourcekey' will...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
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...
0
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...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...

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.