malak laghoz

malak laghoz

  • NA
  • 66
  • 6.4k

How to display full date DD/MM/YYYY

Jun 25 2018 6:34 AM
hello please I have application in aspnet mvc 
my model is 
[Range(1, 31, ErrorMessage = "Date between 1 to 31")]
public int? Day
{
get; set;
}
[Range(1, 12, ErrorMessage = "Month between 1 to 12")]
public int Month
{
get; set;
}
public int Year
{
get; set;
}
public bool isFullBirthDay { get; set; }
 
and this my controller 
 
if (data.isFullBirthDay)
{
if (!data.Day.HasValue)
{
ModelState.AddModelError("Day", "Please enter day value");
return View(oPost);
}
else
{
if (data.Day.HasValue && (data.Day.Value < 1 || data.Day.Value > 31))
{
ModelState.AddModelError("Day", "Please enter day value");
return View(oPost);
}
}
if (data.Month < 1 || data.Month > 12)
{
ModelState.AddModelError("Month", "Please enter proper month");
return View(oPost);
}
//check for leap year
}
else
{
if (data.Month < 1 || data.Month > 12)
{
ModelState.AddModelError("Month", "Please enter proper month");
return View(oPost);
}
}
 
my need is how display  in date DD/MM/YYYY
in view because I have this  fields separate  

Answers (3)