Problem with type conversion


S

shapper

Hello,

I am working on a custom control and I am getting an error on one of my
properties:
"Conversion from type 'Unit' to type 'String' is not valid."

I am using the code which Visual Studio generates when I create a
custom control:

' InfoWidth
<Bindable(True), Category("Layout"), DefaultValue(100),
Localizable(True)> Property InfoWidth() As Unit
Get
Dim _InfoWidth As String = CStr(ViewState("InfoWidth"))
If _InfoWidth Is Nothing Then
Return String.Empty
Else
Return _InfoWidth
End If
End Get
Set(ByVal Value As Unit)
ViewState("InfoWidth") = Value
End Set
End Property

My property is of type WebControls.Unit.

Could someone help me out to solve this?

Thanks,
Miguel
 
Ad

Advertisements

M

Mark Fitzpatrick

Miguel,
You're returning a String.Empty, that won't work because it's type
Unit. You could try returning null or nothing, or instantiating a new Unit
and returning it immediately so it will use the default empty value.
 

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