Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / June 2007

Tip: Looking for answers? Try searching our database.

Help with controls on page

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gbjornholm@gmail.com - 07 Jun 2007 06:04 GMT
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
Eliyahu Goldin - 07 Jun 2007 08:18 GMT
Controls collection includes only direct children. You should loop
recursively to reach every control.

Signature

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

>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
[quoted text clipped - 15 lines]
>
> Thanks in advance
gbjornholm@gmail.com - 07 Jun 2007 12:44 GMT
On Jun 7, 3:18 am, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.org> wrote:
> Controls collection includes only direct children. You should loop
> recursively to reach every control.
[quoted text clipped - 29 lines]
>
> - Show quoted text -

Thanks.  Do you have an example, or a link, on how to loop recursively
thru the form?
bruce barker - 07 Jun 2007 16:45 GMT
writeControlIds(Page);

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

-- bruce (sqlwork.com)

> On Jun 7, 3:18 am, "Eliyahu Goldin"
> <REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.org> wrote:
[quoted text clipped - 27 lines]
> Thanks.  Do you have an example, or a link, on how to loop recursively
> thru the form?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.