473,322 Members | 1,408 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,322 software developers and data experts.

Help with controls on page

I am trying to loop through all the controls on my webform to get it's
ID property. My eventual goal is going to be to reset the text of
specific contols.

Here is a piece of the code I am using, that I found searching through
Google:

Dim control As Control

For Each control In Me.Page.Controls
Response.Write("<BR>" + control.ID)
Next

Unfortunately, all I get returned is the name of my form such as
"frmIndex".

Anyone have any idea or, prefered, an example of what I need to do?

Thanks in advance

Jun 7 '07 #1
3 1255
Controls collection includes only direct children. You should loop
recursively to reach every control.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
<gb********@gmail.comwrote in message
news:11**********************@q66g2000hsg.googlegr oups.com...
>I am trying to loop through all the controls on my webform to get it's
ID property. My eventual goal is going to be to reset the text of
specific contols.

Here is a piece of the code I am using, that I found searching through
Google:

Dim control As Control

For Each control In Me.Page.Controls
Response.Write("<BR>" + control.ID)
Next

Unfortunately, all I get returned is the name of my form such as
"frmIndex".

Anyone have any idea or, prefered, an example of what I need to do?

Thanks in advance

Jun 7 '07 #2
On Jun 7, 3:18 am, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
Controls collection includes only direct children. You should loop
recursively to reach every control.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net

<gbjornh...@gmail.comwrote in message

news:11**********************@q66g2000hsg.googlegr oups.com...
I am trying to loop through all the controls on my webform to get it's
ID property. My eventual goal is going to be to reset the text of
specific contols.
Here is a piece of the code I am using, that I found searching through
Google:
Dim control As Control
For Each control In Me.Page.Controls
Response.Write("<BR>" + control.ID)
Next
Unfortunately, all I get returned is the name of my form such as
"frmIndex".
Anyone have any idea or, prefered, an example of what I need to do?
Thanks in advance- Hide quoted text -

- Show quoted text -
Thanks. Do you have an example, or a link, on how to loop recursively
thru the form?
Jun 7 '07 #3
writeControlIds(Page);

void writeControlIds(Control pc)
{
foreach (Control c in pc)
{
Response.Write(c.ID + "<br />");
writeControlIds(c);
}
}
-- bruce (sqlwork.com)

gb********@gmail.com wrote:
On Jun 7, 3:18 am, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
>Controls collection includes only direct children. You should loop
recursively to reach every control.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net

<gbjornh...@gmail.comwrote in message

news:11**********************@q66g2000hsg.googleg roups.com...
>>I am trying to loop through all the controls on my webform to get it's
ID property. My eventual goal is going to be to reset the text of
specific contols.
Here is a piece of the code I am using, that I found searching through
Google:
Dim control As Control
For Each control In Me.Page.Controls
Response.Write("<BR>" + control.ID)
Next
Unfortunately, all I get returned is the name of my form such as
"frmIndex".
Anyone have any idea or, prefered, an example of what I need to do?
Thanks in advance- Hide quoted text -
- Show quoted text -

Thanks. Do you have an example, or a link, on how to loop recursively
thru the form?

Jun 7 '07 #4

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

Similar topics

3
by: Navin | last post by:
Hello friends... On a single asp.net web page i have a single server-side form that contains a couple of user-controls. Each user control has its own functionality and contains server-side textbox...
2
by: Daniel | last post by:
I'm new to .Net and all of its abilities so I hope this makes sense. Basically I'm confused on when is the appropriate time to use web forms controls vs. regular HTML. For example in ASP...
10
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
2
by: Chad | last post by:
I have a problem that I am desperate to understand. It involves dynamically adding controls to a Table control that is built as a result of performing a database query. I am not looking to...
3
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for...
5
by: serge calderara | last post by:
Dear all, I am new in asp.net and prepare myself for exam I still have dificulties to understand the difference between server control and HTML control. Okey things whcih are clear are the fact...
0
by: Mike Collins | last post by:
I someone can please help, I am about at an end in trying to figure this out. I am adding some dynamic controls to my page (I found out that I was supposed to be doing that in the oninit event,...
53
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code,...
0
by: johnlim20088 | last post by:
Hi, Hi someone can help me on this? Currently I have a Listdata.aspx page with datagrid, I wish to export my datagrid content to excel with following code ( with button export click event):- ...
2
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi Guys, I have a real serious problem that stoped me doing any progress in my project. in one of my webpages I have a wizard of more then 13 pages and in every page some Ajax controls,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.