Search code examples
c#asp.netwpfvalueconverter

Anything similar to WPF's ValueConverters for ASP.Net?


After doing a project with WPF and getting very much attached to it's excellent databinding capabilities, I have now moved back to ASP.Net and am starting to miss some of WPF's stuff.

My question is...is there anything similar to WPF's ValueConverters for ASP.Net?

For example, I want a UserControl to expose a public property which is an IEnumerable<int> and the user can enter such from the source:

<asp:MyControl1 runat="server" ID="something" TheList="1,3,5,7"/>

And then the value in TheList will be converted to an IEnumerable<int>, with something like a ValueConverter of WPF's.

[Update] Solution

Thanks to Nathan Baulch's mention of a TypeConverter, I got across this question and I managed to build a string to list converter.


Solution

  • I would recommend you take a look at System.ComponentModel.TypeConverter.

    This article on CodeProject includes an example that is quite similar to yours involving latitude and longitude strings.