473,785 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to make a "for each" in WebControls?

Hello all,
I have webform1, and i need to make a bow to catch all textbox in my
webform1.
I tray this, but don't function.

Dim obj As System.Web.UI.W ebControls.Text Box
Dim cont As Integer
For Each obj In Page.Controls.
If TypeOf obj Is System.Web.UI.W ebControls.Text Box Then
obj.Text = "It is a Textbox"
End If
Next

Somebody know to make this?
Thanks
Dexter
Nov 18 '05 #1
2 1411
Hi Dexter,

Make sure you are looking in the right collection for the TextBox and don't
be too specific with your initial object. Try the code below and let us know
if it helps?

Ken

<%@ Page Language="VB" trace="true" Debug="true" %>
<script runat="server">

Sub page_Load
Dim obj As Object
For Each obj In Page.Controls(1 ).controls
If TypeOf obj Is System.Web.UI.W ebControls.Text Box Then
obj.Text = "It is a Textbox"
End If
Next
end sub

</script>
<html>
<head>
</head>
<body style="BACKGROU ND: url(http://www.gc.ca/images/rollingflag.jpg) ivory
no-repeat center center">
<form runat="server">
<asp:TextBox id="TextBox1" runat="server"> </asp:TextBox>
<asp:TextBox id="TextBox2" runat="server"> </asp:TextBox>
<asp:TextBox id="TextBox3" runat="server"> </asp:TextBox>
<!-- Insert content here -->
</form>
</body>
</html>
"Dexter" wrote:
Hello all,
I have webform1, and i need to make a bow to catch all textbox in my
webform1.
I tray this, but don't function.

Dim obj As System.Web.UI.W ebControls.Text Box
Dim cont As Integer
For Each obj In Page.Controls.
If TypeOf obj Is System.Web.UI.W ebControls.Text Box Then
obj.Text = "It is a Textbox"
End If
Next

Somebody know to make this?
Thanks
Dexter

Nov 18 '05 #2
Will this also catch text boxes that are in containers in the specified
container? If not, is there a generic container object that can be used
to make something more recursive? I don't have the ability to test it
at the moment, but I was thinking something like:

Sub page_Load
changeText(Page .Controls(1).co ntrols)
end sub

Sub changeText(ByVa l myContainer As $CONTAINER_TYPE )
Dim obj As Object
For Each obj In Page.Controls(1 ).controls
If TypeOf obj Is System.Web.UI.W ebControls.Text Box Then
obj.Text = "It is a Textbox"
ElseIf TypeOf obj Is $CONTAINER_TYPE Then
changeText(obj)
End If
Next
End Sub
What would $CONTAINER_TYPE be?
Regards,
David P. Donahue


Ken Cox [Microsoft MVP] wrote:
Hi Dexter,

Make sure you are looking in the right collection for the TextBox and don't
be too specific with your initial object. Try the code below and let us know
if it helps?

Ken

<%@ Page Language="VB" trace="true" Debug="true" %>
<script runat="server">

Sub page_Load
Dim obj As Object
For Each obj In Page.Controls(1 ).controls
If TypeOf obj Is System.Web.UI.W ebControls.Text Box Then
obj.Text = "It is a Textbox"
End If
Next
end sub

</script>
<html>
<head>
</head>
<body style="BACKGROU ND: url(http://www.gc.ca/images/rollingflag.jpg) ivory
no-repeat center center">
<form runat="server">
<asp:TextBox id="TextBox1" runat="server"> </asp:TextBox>
<asp:TextBox id="TextBox2" runat="server"> </asp:TextBox>
<asp:TextBox id="TextBox3" runat="server"> </asp:TextBox>
<!-- Insert content here -->
</form>
</body>
</html>
"Dexter" wrote:

Hello all,
I have webform1, and i need to make a bow to catch all textbox in my
webform1.
I tray this, but don't function.

Dim obj As System.Web.UI.W ebControls.Text Box
Dim cont As Integer
For Each obj In Page.Controls.
If TypeOf obj Is System.Web.UI.W ebControls.Text Box Then
obj.Text = "It is a Textbox"
End If
Next

Somebody know to make this?
Thanks
Dexter

Nov 18 '05 #3

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

Similar topics

5
5002
by: Orin Hargraves | last post by:
I'm formatting data in a text file using a "For Each aPara" statement along with a "Next aPara." How do I make the thing stop when it reaches the end of the file, rather than starting again at the top of the file and looping forever? Thanks, I'm new at this. Orin Hargraves
3
2126
by: Phil | last post by:
Hi everybody, I am a XSLT beginner and the following problem really makes me crazy ! I have a main "contacts.xml" document which contains references to several contact data XML files. My aim is to process the contacts in a single-pass XSLT process. That is why the "document()" function is what I need. I call the "document()" XPath function from a "for-each" instruction.
8
2035
by: Calan | last post by:
I have a server-side ASP script that dynamically creates an input form from a database table. The table contains a field name, the table where values are stored, type of input control, value for a label, etc. What I need to do is create a JS validation routine that will check each control for valid input, regardless of what the control name is. If it is a "select", it needs to verify the index is > 1. If it is an "input", it needs to...
2
3167
by: jwalton | last post by:
I have a web site (for a client) where I am now using a considerable number of XML files. Previously the files were updated off-line, and FTPd to make live. I now need to allow "user editors" to edit the XML data. These users are primarily "business knowledge" experts; intelligent but not necessarily IT literate. I need to provide a simple XML editor to allow them (e.g.) to edit a simplified RDF style metadata base (actually a modified...
21
13849
by: Helge Jensen | last post by:
I've got some data that has Set structure, that is membership, insert and delete is fast (O(1), hashing). I can't find a System.Collections interface that matches the operations naturally offered by Sets. - ICollection cannot decide containment - IList promises indexability by the natural numbers, which is not achievable (since i hash elements, not sort them). - IDictionary is definatly not setlike. Although I can, of course, define...
2
922
by: michael | last post by:
I am creating a ASP.NET website and in doing so, I am going to use "TABS" at the top of the page. These "tabs" are the same for the entire website. Is there an easy way (other than Frames) to "include" these common button/tab controls on the top of every ASP.NET page of mine? Thanks in advance...
4
1607
by: Burt | last post by:
I'm working on a Windows app that pulls data from SQL Server, displays it on various forms and grids, and allows the user to update, insert, delete data. Some but not much business logic, just validation and and some processing, like allowing the user to import data into the db from upstream. Trying to decide between datasets, and creating an object model layer. Articles like...
0
1992
by: dan | last post by:
Hi, I've been using a GridView for some time but this is the first time I need to delete a row in the grid whose primary key consists of 2 fields (table columns). I have a table with primary key set to c1,c2 where c1 is a uniqueidentifier and c2 is int. The DataKeyNames in the gridview is defined as follows: DataKeyNames="c1,c2".
10
1745
by: hall.jeff | last post by:
As a relative new comer to Python, I haven't done a heck of a lot of hacking around with it. I had my first run in with Python's quirky (to me at least) tendency to assign by reference rather than by value (I'm coming from a VBA world so that's the terminology I'm using). I was surprised that these two cases behave so differently test = ,] x = test x = 5 test
0
9647
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, 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...
0
9489
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10162
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 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...
0
9959
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7509
isladogs
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...
1
4061
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
2
3665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2893
bsmnconsultancy
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...

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.