473,408 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Problem with type conversion

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
1 958
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Jon Slaughter | last post by:
I'm having a little trouble understanding what the slicing problem is. In B.S.'s C++ PL3rdEd he says "Becayse the Employee copy functions do not know anything about Managers, only the Employee...
5
by: Yodai | last post by:
Hi all! I have an int that comes with a value like 0x07fa and I have to turn it into a float value of 204.2 decimal to display it.... if I try to divide it by 10 I get bogus numbers. I presume...
7
by: Madhu Gopinathan | last post by:
Hi, I hope this is the right forum for this question. I am extending ICollection to create a Collection Type (say MyCollection) wherein I can control the types of objects being added to the...
3
by: Tom Jastrzebski | last post by:
Hello everybody, Here is another problem with generics I come across. Let's say I want to implement a structure performing some operations on some numeric type. I can not than just return...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
2
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c...
39
by: Martin Jørgensen | last post by:
Hi, I'm relatively new with C-programming and even though I've read about pointers and arrays many times, it's a topic that is a little confusing to me - at least at this moment: ---- 1)...
8
by: SpreadTooThin | last post by:
Basically I think the problem is in converting from a 32 bit integer to a 16 bit integer. I have two arrays: import array a = array.array('L', ) b = array.array('H', ) b = a
0
by: egbert.beuker | last post by:
Hi, I encountered a conversion problem in my .net web app (c#), and I hope someone can help me: I'm working on a generic way to store data in a database with a few generated classes. I want...
9
by: crater | last post by:
The following function is not updating an image in opera 9.02. upd_on = new Image() upd_on.src = "images/update_button.gif" function enableUpdate() { var update =...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.