I want to allow multiple input-formats for a input field. In my case it is a Longitude field. In the DB I set it to decimal(18,10). It expects to recieve a comma-separated-value e.g. 16,2345678 but Google Maps or some Users are using a dot e.g. 16.2345678 I dont want to return an error but simply be glad and transform it to the expected db-format.
I tried to do it in my MetaData Validation Class (using Entity Framework)
public partial class Job
/*[Bind(Exclude = "ID")]*/
public class JobMetaData
{
public object Longitude
{
get { return this.Longitude; }
set { this.Longitude = value; /* Seems that this point isnt reached*/ }
}
but unfortunatly the setter is not called and the ViewState.isValid returns simply false.
[HttpPost]
public ActionResult Edit(Job model)
{
// parse the long-lat if needed here??
try
{
if (!ModelState.IsValid)
{
Where should I try to parse the value to allow both values (comma-separated and dot-separated) transform them and safe it.
I have the same issue for another field: I would like the user to enter 4 or 4€, in case just delete the €-sign and save it as a number to db.
Thanks for your help.