By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,870 Members | 1,189 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,870 IT Pros & Developers. It's quick & easy.

Problem with type conversion

P: n/a
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

Oct 13 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.

--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"shapper" <md*****@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
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

Oct 13 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.