Server Side Validation
class OrdersViewModel : ViewModelHelper
{
public readonly Northwind.Models.Orders Orders = new Northwind.Models.Orders();
public readonly Northwind.Models.Shippers Shippers = new Northwind.Models.Shippers();
public OrdersViewModel()
{
From = Orders;
Relations.Add(Shippers, Shippers.ShipperID.IsEqualTo(Orders.ShipVia));
AllowUpdate = true;
Where.Add(Orders.OrderDate.IsGreaterOrEqualTo(1997, 1, 1));
Shippers.CompanyName.Caption = "Shipper Name";
MapColumn(Orders.OrderID,
Orders.CustomerID,
Orders.OrderDate,
Orders.ShipVia,
Shippers.CompanyName);
MapExperssion("ServerSideDayOfWeek", () => u.NDOW(u.DOW(Orders.OrderDate)));
}
protected override void OnSavingRow()
{
if (Orders.OrderDate.Year < 1995)
Message.ShowError("Please enter valid date");
}
}
Server side validation using ModelState
protected override void OnSavingRow()
{
- if (Orders.OrderDate.Year < 1995)
- Message.ShowError("Please enter valid date");
ModelState.AddError(Orders.OrderDate, "invalid date");
ModelState.Required(Orders.OrderID);
}
Help us improve, Edit this page on GitHub
or email us at info@fireflymigration.com