Array type Server Control Property

I have a server control that needs an array of strings.
How you manage this?
I could add a property of type string like;
public virtual string Items{get{}set{}}
and when the developer fills the property like;
"string1;string2;string3"
then I can pick the strings from that property for my use but is this the right way?

I search the web to find a property (Designer) that takes items like  a listview, a combobox but could find anything.
I'm using VS 2005 Asp.Net with C#.  
Thanks,
LVL 5
kosturdurAsked:
Who is Participating?
 
mikeuttCommented:
Have you tried creating a property that is a list of objects to hold the strings. Then decorate that property with
[PersistenceMode(PersistenceMode.InnerProperty)]

Sort of like this

public List<TheString> _listOfStrings;
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[PersistenceMode(PersistenceMode.InnerProperty)]
public List<TheString> ListOfStrings
{
get { return _listOfStrings; }
set { _listOfStrings = value; }
}


Then at design time your ASP control can be marked up like so


<cc1:webcustomcontrol1 id="WebCustomControl1_1" runat="server">
<ListOfStrings >
<cc1:TheString StringValue="one" />
<cc1:TheString StringValue="two" />
<cc1:TheString StringValue="three" />
<cc1:TheString StringValue="four" />
</ListOfStrings>
</cc1:webcustomcontrol1>

Check out http://msdn2.microsoft.com/en-us/library/system.web.ui.persistencemode(VS.80).aspx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.