*Controller
[.cs]
public void Edit(EditModel data)
{
if (ModelState.IsValid)
{
//is valid data
}
else
{
//get error message
var errors = ModelState.Select(x => x.Value.Errors)
.Where(y => y.Count > 0)
.ToList();
}
}
[.cs]
public void Edit(EditModel data)
{
if (ModelState.IsValid)
{
//is valid data
}
else
{
//get error message
var errors = ModelState.Select(x => x.Value.Errors)
.Where(y => y.Count > 0)
.ToList();
}
}
留言
張貼留言