Skip to content

Instantly share code, notes, and snippets.

@jmprado
Created January 21, 2013 22:13
Show Gist options
  • Save jmprado/4589992 to your computer and use it in GitHub Desktop.
Save jmprado/4589992 to your computer and use it in GitHub Desktop.
@model DateTime?
@{
//Salva o valor como uma string validando a nulidade do objeto passado
string dateValue = Model.HasValue ? Model.Value.ToString("dd/MM/yyyy") : string.Empty;
}
@Html.TextBox("", dateValue, new { @class = "datepicker", maxlength = 10, @readonly = true })
@model Decimal?
@{
//Formata o decimal para pt-BR substituindo o ponto pela vírgula
var decimalValue = Model.HasValue ? Model.Value.ToString("C").Replace(".", "").Replace(",", "") : string.Empty;
}
@Html.TextBox("", decimalValue, new { maxlength = "12", @class = "number" })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment