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

Looping thru controls - part 2!!


i have the routine setup as below. the ctlCollection is populated with Page.Controls. but it only ever brings back 3 controls even though there is more than this on the page

the control types it returns are

1 x "System.Web.UI.ResourceBasedLiteralControl"
1 x "System.Web.UI.HtmlControls.HtmlForm"
1 x "System.Web.UI.LiteralControl"

where am i going wrong?

Cheers,
Craig
Private Sub SetBackgroundColour(ByVal ctlCollection As ControlCollection)

Dim ctl As Control

Try

For Each ctl In ctlCollection

If ctl.GetType.ToString = "Textbox" Then

If CType(ctl, TextBox).Enabled = False Then

CType(ctl, TextBox).BackColor = Color.Transparent

Else

CType(ctl, TextBox).BackColor = Color.LightGoldenrodYellow

End If

End If

If ctl.GetType.ToString = "DropDownList" Then

If CType(ctl, DropDownList).Enabled = False Then

CType(ctl, DropDownList).BackColor = Color.Transparent

Else

CType(ctl, DropDownList).BackColor = Color.LightGoldenrodYellow

End If

End If

Next

end sub

Nov 19 '05 #1
6 1061
Where are you invoking SetBackgroundColour method? And what is the
value of the paramter that you are passing?

Page.Controls?
--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
--------------------------------

Nov 19 '05 #2
i have a SetMode Method which runs on the page load. For an Add, Edit or
ViewMode

within SetMode i call EnableFields, followed by SetBackGroundColour

and yes the parameter being passed in is Page.Controls

Cheers,
Craig

"MasterGaurav" <ga**********@gmail.com> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.com...
Where are you invoking SetBackgroundColour method? And what is the
value of the paramter that you are passing?

Page.Controls?
--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
--------------------------------

Nov 19 '05 #3
Here... try passing "this.Controls".

void Page_Load(...)
{
SetBackgroundColour(Controls);
}
--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
--------------------------------

Nov 19 '05 #4
nope still no joy!

"MasterGaurav" <ga**********@gmail.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
Here... try passing "this.Controls".

void Page_Load(...)
{
SetBackgroundColour(Controls);
}
--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
--------------------------------

Nov 19 '05 #5
What version of ASP.Net are you using?

AFAIK, this is how it is supposed to work... in 1.1 and this is how I
have been working with in IBuySpy.
--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
--------------------------------

Nov 19 '05 #6
yep we are using 1.1

the page uses frames, would that cause problems?

"MasterGaurav" <ga**********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
What version of ASP.Net are you using?

AFAIK, this is how it is supposed to work... in 1.1 and this is how I
have been working with in IBuySpy.
--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
--------------------------------

Nov 19 '05 #7

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

Similar topics

8
by: RC | last post by:
I have a table that lists many box numbers. Each box number has a Pallet Number (indicating which pallet the box is in). When the Pallets are loaded into a shipping Container I need to update the...
4
by: Nick | last post by:
Hi - I'm trying to loop through the textboxes on a page to unlock them for editing. The Enabled property is set to false, and the following code is on an 'Edit' button on the form. Can anyone tell...
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...
1
by: Jim in Arizona | last post by:
Using VB .. Is there a way to loop through all drop down lists on a web form checking for a specific value (ddlDropDown.SelectedValue) and then, based on that value, cause a specific label to go...
2
by: pob | last post by:
Whats the difference between using a control or a listbox when looping thru a listbox. In example 1 it dims a listbox and an example 2 it dims a control. Please explain. Thanks in advance ...
1
by: pds79 | last post by:
Hi everyone, I'm a newbie to the forum. I have an issue and was hoping to get some assistance/ideas: Im trying to read a XML file into two record sets. I can acheive looping through the...
1
by: tshad | last post by:
I was trying to do this in Javascript but found I can't do spans (which is what Labels turn into). I can do a loop thru a control list something like: Public Sub LoopingControls(ByVal oControl...
6
by: mahowe | last post by:
Hi, I have had this problem for a while and have not been able solve it. What im looking at doing is looping thru my patient table and trying to organise the patients in to there admission...
4
by: sparks | last post by:
well I am trying to get around looking at all the buttons with a case statement so I was trying this. Public Sub looking(ctlname) Dim ctl As OptionGroup Dim btn As ToggleButton ctl =...
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...
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
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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...

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.