![]() |
How to access property of user control with variable ID?
Hello everybody.
I have two instances of same user control. This user control has a property. Each instance has different value of this property and different ID. For example: Code:
<uc:UserControl ID="UC1" runat="server" prop="value1" />I try to do this by the following code: Code:
int I;Of course this error occurred because UC didn't compiled in design mode. How I can solve this problem? Thanks for any reply. |
Without seeing the UC code it is going to be near impossible to answer- at first glance I don't see anything that would be 'wrong'... provided that those controls have a property called 'prop'. if it is not compiling then there is something wrong, and trying to correct something that you don't know why it's 'wrong' with outstanding compilation errors is also near impossible... you may simply have something wrong with a snip of code somewhere that makes the objects not build- who knows...
here's an example of two drop down list objects being accessed that reside on same page and their properties being accessed (note it is similar to your attempts) Code:
List<ListItem> li_actions = new List<ListItem>();Let's first focus on 'why' your code is not compiling and resolve those problems first; then move on to why your attempts to access properties are failing out Worth noting... if that property is a private property, then it will error out with that message (or something similar), because to the outside world (code included) that property does not exist. <- that may be your problem |
| All times are GMT +1. The time now is 02:33 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.