Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 24th, 2005, 12:40 PM
Authorized User
 
Join Date: Mar 2004
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default Accessing Controls in Web Form

I'm trying to gain access to the control collection for a web form. What I would like to accomplish is to go through each control on the web page and set it's properties if it meets certain criteria.

For example, I would like to find all the textbox controls and set the background color based on whether or not it's a read-only field.

Any help is appreciated. Thanks.
 
Old March 24th, 2005, 04:48 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

I couldn't ever go through Page.Controls, I needed to go to the form level, so I do:

'Controls(1) is the HtmlForm object
for each objControl As Control in Page.Controls(1).Controls
  if (typeof(objControl) is TextBox) then
    'Do whatever
  end if
next

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
Web Form and User Controls CSharpSeeker C# 2005 1 August 22nd, 2007 03:15 PM
Accessing the MDI form controls from child forms krishnasamaga Visual Studio 2005 1 June 7th, 2006 08:09 AM
Accessing Web User Controls from code aquaboltar ASP.NET 2.0 Basics 0 October 26th, 2004 04:04 PM
Accessing controls in another form Ramakrishna General .NET 1 September 6th, 2004 10:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.