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

object component

On an aspx page with C# code behind I am trying to programmatically change
the ImageUrl of various ImageButtons in response to the text contained in
corresponding label controls.

The following code works:

PropertyDescriptorCollection properties =
TypeDescriptor.GetProperties(this.ImageButton12);

PropertyDescriptor myProperty = properties.Find("ImageUrl", false);

myProperty.SetValue(ImageButton12,@"C:\Inetpub\www root\BB\images\X.BMP")

Now I want to replace all references to "ImageButton12" in the above code
with a member of an array such as "pram[2]" so that I can loop through all
the ImageBoxes easily in code.

Where:

string[] pram = new string[]
{"Label33","Label34","Label35","Label36","Label37" ,"Label38","Label39"};

or

string[] pram = new string[] {"this.Label33","this.Label34","this.Label35","
this.Label36"," this.Label37"," this.label38"," this.Label39"};

or

Object[] pram = new Object[]
{"this.Label33","this.Label34","Label35","Label36" ,"Label37","Label38","Label39"};

Each time a get an "Object reference not set to an instance of an object"
error.

I have even tried changing the array to a component array, but then I get a
"Can't implicitly change type" error.

The data type specified is "object component" I need to build an array of
object components that I can address by index number.

Any insight would be appreciated.

Thanks,

Jim


Dec 3 '05 #1
1 1064
Although I'm more a VB programmer, I think I know the answer:
(correct me if I'm wrong)

in the line :
myProperty.SetValue(ImageButton12,@"C:\Inetpub\www root\BB\images\X.BMP")

ImageButton12 is a object, in this case a button.
What you are trying to do is to replace a button-object with a string.
The setvalue method then does not recognize it as an object and gives an
error.

rg.
Eric


"Jim McGivney" <mc****@no-spam.sbcglobal.net> schreef in bericht
news:u6****************@tk2msftngp13.phx.gbl...
On an aspx page with C# code behind I am trying to programmatically change
the ImageUrl of various ImageButtons in response to the text contained in
corresponding label controls.

The following code works:

PropertyDescriptorCollection properties =
TypeDescriptor.GetProperties(this.ImageButton12);

PropertyDescriptor myProperty = properties.Find("ImageUrl", false);

myProperty.SetValue(ImageButton12,@"C:\Inetpub\www root\BB\images\X.BMP")

Now I want to replace all references to "ImageButton12" in the above code
with a member of an array such as "pram[2]" so that I can loop through
all the ImageBoxes easily in code.

Where:

string[] pram = new string[]
{"Label33","Label34","Label35","Label36","Label37" ,"Label38","Label39"};

or

string[] pram = new string[]
{"this.Label33","this.Label34","this.Label35"," this.Label36","
this.Label37"," this.label38"," this.Label39"};

or

Object[] pram = new Object[]
{"this.Label33","this.Label34","Label35","Label36" ,"Label37","Label38","Label39"};

Each time a get an "Object reference not set to an instance of an object"
error.

I have even tried changing the array to a component array, but then I get
a "Can't implicitly change type" error.

The data type specified is "object component" I need to build an array of
object components that I can address by index number.

Any insight would be appreciated.

Thanks,

Jim



Dec 3 '05 #2

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

Similar topics

3
by: Ian | last post by:
The beginning of my assembly that I am getting the access error from looks like this. ********************************* Imports System.EnterpriseServices Imports System Imports...
2
by: brazilnut52 | last post by:
I am going to outline the steps I go through to produce the problem. Hopefully this will help you understand the problem better I have created a simple COM DLL in .NET by using the COM class...
9
by: gulu man | last post by:
Hi, What is the substitute for COM objects in .NET? How can I create something similar to com in .net? Is it still possible? Thank you
3
by: Pexi | last post by:
Hi, we have a component developed with VB6 (compiled as a single threaded dll), which we have used as Application level object for several years in classic asp without problems. Yet now, when we...
11
by: Andrus | last post by:
I'm implementing entity object which should populate its properties from database when property is first referenced. In RDL reports I use object properties like MyObject.MyProperty MyObject...
3
by: gary.bernstein | last post by:
I want to call a singleton getInstance function to retrieve a templatized object without knowing what types were used to create the singleton object in the first call to getInstance. How can I do...
3
by: Stephen Torri | last post by:
Here is my attempt at implementing a object factory. The purpose of this is to replace a large switch statement in a factory class with the functors. I get an error at line 88, marked, "expected...
1
by: =?Utf-8?B?VmVua2F0ZXNhbiBT?= | last post by:
Hi, I have a requirement of consuming a connection object returned from a COM component deployed in COM+ application. I have given the need for this requirement end of my query. My component...
7
by: colin | last post by:
Hi, Im a bit confused about when you cast a value type to an object. I have a property grid wich stores the data and the defualt as objects. the data is limited to primitive types, structs and...
2
dream party
by: dream party | last post by:
Inserting a Flash (SWF, FLV) file into HTML web page is already an old and familiar thing to all of us. It is a rather non-flexible thing that just to edit some options in the template. However, I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.