J
Jim McGivney
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\wwwroot\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
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\wwwroot\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