using the Items property in the design time property window

R

Ryan Taylor

I hope this is the proper forum. I posted this problem in the wrong one
previously. I have a custom server control that I am building. Implementing
simple properties like strings and ints seems to be pretty straightforward
and there are a lot of examples. However, I have a need to allow the user to
add multiple items. Each item would be a custom class that contains a few
properties, id, name etc. I cannot seem to get this functionality to work,
and I cannot find any examples anywhere, I've been googling forever.

Ultimately, my goal is to create a custom server control, that renders out
images with javascript. An additional "action" parameter on each item would
determine the action that the javascript executes. And I want the designer
to be able to configure the control at design time through the Items
property.

Any assistance would be appreciated very much.
Ryan
 
C

Chad

Ryan,

I'm sorry I don't have the answer, but I'm in the same boat. The native
types like string and ints seem to be handled correctly. But I've got a
property that holds a string array and a property that points to
another control. I can fill these properties in at design time, but
when I run the values in the properties are lost. Which I think is the
same problem you are having. Yep lots of examples on properties of
strings and ints, but I've been looking as well for a more complicated
example and don't see any. Hopefully there will be some reading that
has the answer. If you find the answer please post back to let me know.

Thanks ...
 
R

Ryan Taylor

Chad,

I haven't even gotten this far. I have managed to add one custom item
through the property window, but that is it. The Add/Remove buttons are then
disabled. If I close the property window, they are still disabled, and there
doesn't appear to be an item in the members list, however, one item shows in
the right in the properties list. Very strange.

Do you have an example of how you got where you are?
I am not sure what I am missing, documentation in this area is so scarce.
 
P

Paul Louth

Hi Ryan, Chad, unfortunately I don't have the answer either, and am in the
same boat. I posted another topic before seeing yours titled: "Collections
as properties".

I have got as far as creating a control which I can add multiple items to in
the designer, but when I switch to the HTML view the value is "(Container)".
Which looks like a ToString() returned value. So I'm wondering whether the
container should serialise the items, but I am really clutching at straws
atm.

Paul.
 
P

Paul Louth

Ok, found how to do it, you need to set the PersistenceMode attribute to
InnerProperty for the property you want embedding:

[Bindable(true), PersistenceMode(PersistenceMode.InnerProperty)]
public YourCollection Collection
{
get {}
set {}
}

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top