I want to extend the default model binding to be more smart when dealing with numbers. The default works very bad when are commas and decimals points in the game.
I was trying the do a new binder
Public Class SmartModelBinder
Inherits DefaultModelBinder
Protected Overrides Sub SetProperty(controllerContext As ControllerContext, bindingContext As ModelBindingContext, propertyDescriptor As System.ComponentModel.PropertyDescriptor, value As Object)
If propertyDescriptor.PropertyType Is GetType(Decimal) Or propertyDescriptor.PropertyType Is GetType(Decimal?) Then
If value Is Nothing Then
value = 0
End If
End If
MyBase.SetProperty(controllerContext, bindingContext, propertyDescriptor, value)
End Sub
End Class
But the value is already converted at this point
How can I extend the binder to get the string value from the form and perform a different transformation?