9
I'm working on an MVC3 application with Razor. I'm having troubles using Dates and doubles on my views. Both my Windows and Visual Studio are English, but I want to customize the culture of my project in "it-IT". I found several articles how to manage different cultures, through the JQuery Validation Plugin or directly setting the culture on the page, but I'm a lot confused!!! The format I want use for dates is "DD/MM/YYYY", while for double is 1.234,32. So,
- How can I tell to Visual Studio how to use these formats (I checked on the Visual Studio's settings and there is only English)?
- MVC injects code to validate my fields, how to change it?
- What is the best approach?
Obviously any suggest would be appreciated. I post the code of my project:
Offerta.cs
[MetadataType(typeof(Offerta_Validation))]
public partial class Offerta
{
}
public class Offerta_Validation
{
[HiddenInput(DisplayValue = false)]
public int IDOfferta { get; set; }
[StringLength(300, ErrorMessage = "Campo troppo lungo")]
[Required(ErrorMessage = "Campo obbligatorio")]
public string Titolo { get; set; }
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:N2}")]
[Required(ErrorMessage = "Campo obbligatorio")]
[Price(MinPrice=0.01)]
public decimal PrezzoIniziale { get; set; }
[Required(ErrorMessage = "Campo obbligatorio")]
[Integer]
public int BuoniScontiMinimo { get; set; }
public string Sconto { get; set; }
[Date]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:d}")]
public System.DateTime DataAttivazione { get; set; }
[DataType(DataType.MultilineText)]
[AllowHtml]
public string Sintesi { get; set; }
[DataType(DataType.MultilineText)]
[Required(ErrorMessage = "Inserire le condizioni")]
[AllowHtml]
public string Condizioni { get; set; }
[DataType(DataType.MultilineText)]
[Required(Erro