Groups | Blog | Home
all groups > asp.net building controls > september 2005 >

asp.net building controls : Help needed for "generic" System.Object Converter


microsoft.newsgroups.com
9/21/2005 7:02:17 PM
Hi, I have custom web server control with one property being of type
System.Object.

At design time, only string values are allowed to be entered in the property
window. If "StringConverter" is used for the TypeConverter attribute, a user
can enter string values for this property and those values get serialized to
the aspx.

However, at run time an exception gets raised (as StringConverter can only
convert to a string, not from a string).

The question is: how to build a custom type converter for the generic
System.Object type/class? I guess this should inherit from StringConverter
but am unsure how to code the ConvertTo and CanConvertTo methods?


~ Gajba




intrader
9/21/2005 11:18:04 PM
[quoted text, click to view]
I think that you are pointing in the correct direction. You can use
reflection to find out the 'from' type.
Zarko Gajic
9/22/2005 9:42:53 AM

[quoted text, click to view]

And this is exactly where I stuck ;)

Thanks.

intrader
9/22/2005 6:01:36 PM
[quoted text, click to view]
Sorry, you can check http://odetocode.com/Articles/288.aspx

The method is GetType.


AddThis Social Bookmark Button