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

Problem Passing control as a param into a class function

I am trying to make use of the following type of code in a ".cs" class. I
need to pass the Page.Controls collection into a class located in a ".cs"
file (not code behind). I am able to do this with the this mechanism but I
need to do it as a reference or out type.

My goal is to use a database table to do pre button security lookups and
disable
any button that the user does not have security for.

I would be very greatful for any input. Even a better mouse trap.

Thanks in advance
Grosch

foreach (Control c in Page.Controls)
{
foreach (Control childc in c.Controls)
{
if (childc is Button)
{
string sID = childc.ID.ToString();
//do db button lookup and disable if necessary
}
}
}
Nov 16 '05 #1
2 3363
> I am able to do this with the this *mechanism but I need to do it as
a reference or out type.

Why? I would think that you just need to declare a parameter of type
ControlCollection and that's that. What kind of problem do you run into
if you don't make it "ref" or "out"?

Nov 16 '05 #2


"Bruce Wood" wrote:
I am able to do this with the this Â*mechanism but I need to do it as a reference or out type.

Why? I would think that you just need to declare a parameter of type
ControlCollection and that's that. What kind of problem do you run into


ControlCollection with ref yields the following errors.
t.aspx.cs(50,40): error CS0206: A property or indexer may not be passed as
an out or ref parameter
y.cs(40,35): error CS0117: 'System.Web.UI.ControlCollection' does not
contain a definition for 'Controls'


if you don't make it "ref" or "out"?
It did however work with out the ref. Thank you very much. One thing
Visible exposed but enabled was not.
Thanks again, I hit the wall on this one. I am still at the humble level of
C#

Nov 16 '05 #3

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

Similar topics

1
by: mjcast | last post by:
I have been working on an ActiveX control in C#. It is packaged in a Windows Control library and the code is in a user control. The control is used as an automation receiver that is used to update a...
9
by: SB | last post by:
Ok, very simple problem. I'm trying to update a value by calling a function using pass by reference, but it does not update the value. In short, the value I'm trying to update is balance, which is...
7
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID...
2
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell...
4
by: steve bull | last post by:
I have created a UserControl and added it to my toolbox. It appears in the toolbox with the icon I created for it. The problem is that when I drag the control onto a form no code is generated. If I...
4
by: marek.rocki | last post by:
First of all, please don't flame me immediately. I did browse archives and didn't see any solution to my problem. Assume I want to add a method to an object at runtime. Yes, to an object, not a...
0
by: Brian Henry | last post by:
Ok I've never implemented a snap location before so I dont really know what im doing wrong here... anyways, I am making a custom slider control that takes dates as its values instead of integers......
5
by: althafexcel | last post by:
hi everyone Im trying to include an external js in my aspx page under the head tag, it doesn't load or it displays an object expected error whenver the function from the .js is called. Actually...
1
by: KhoaNguyen | last post by:
i have two classes..one is a base and the other is inherited from the base class Below is my code -------ConnectionProvider class--------------------- using System; using...
4
by: pankajsingh5k | last post by:
Hi guys, These question is for all the experts... Please help me before my brain explodes The problem is again with the formview control.. I have a formview and i have to use it that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
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
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,...
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.