Property


S

shapper

Hello,

I am creating a custom web control where one of its properties is a
generic list:

<Bindable(True), Category("Format"), DefaultValue(""),
Localizable(True)> Property Features() As Generic.List(Of Feature)
Get
If CStr(ViewState("Features")) Is Nothing Then
Return String.Empty
Else
Return CStr(ViewState("Features"))
End If
End Get
Set(ByVal Value As String)
ViewState("Features") = Value
End Set
End Property ' Features

This is the default way to create a property in a web control, as far
as I know.

I am getting an error saying that string cannot be converted to a
generic list.

How should I create my property?

Thanks,

Miguel
 
Ad

Advertisements

G

GeezerButler

Hello,

I am creating a custom web control where one of its properties is a
generic list:

<Bindable(True), Category("Format"), DefaultValue(""),
Localizable(True)> Property Features() As Generic.List(Of Feature)
Get
If CStr(ViewState("Features")) Is Nothing Then
Return String.Empty
Else
Return CStr(ViewState("Features"))
End If
End Get
Set(ByVal Value As String)
ViewState("Features") = Value
End Set
End Property ' Features

This is the default way to create a property in a web control, as far
as I know.

I am getting an error saying that string cannot be converted to a
generic list.

How should I create my property?

Thanks,

Miguel

That's because your property should return a Generic.List but you are
returning a string.
 

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

Similar Threads


Top