Created
August 30, 2012 22:21
-
-
Save cleytonferrari/3542947 to your computer and use it in GitHub Desktop.
Exemplo de Data em ASP.Net MVC 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Web.Mvc; | |
using ExemploDeDataPreenchida.Models; | |
namespace ExemploDeDataPreenchida.Controllers | |
{ | |
public class HomeController : Controller | |
{ | |
// | |
// GET: /Home/ | |
public ActionResult Index() | |
{ | |
var produto = new Produto | |
{ | |
DataVencimento = DateTime.Now | |
}; | |
return View(produto); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@model ExemploDeDataPreenchida.Models.Produto | |
@{ | |
ViewBag.Title = "Exemplo de data preenchida"; | |
} | |
<h2>Exemplo de data preenchida</h2> | |
<form action="" method="GET"> | |
Nome: | |
<input type="text" name="Nome" id="Nome" value=""/> | |
<br/> | |
Data | |
<input type="text" nome="DataVencimento" id="DataVencimento" value="@Model.DataVencimento"/> | |
<br/> | |
<input type="submit" value="Enviar"/> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.ComponentModel.DataAnnotations; | |
namespace ExemploDeDataPreenchida.Models | |
{ | |
public class Produto | |
{ | |
public int ProdutoId { get; set; } | |
public string Nome { get; set; } | |
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}")] | |
public DateTime DataVencimento { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment