开发者

Model object validates (TryValidateModel) but does not update (TryUpdateModel)

The Model object refuses to update on production server but has no issues on development machine. For the purposes of testing, I retrieve the model object and then immediately check its validation and update states, for example:

        Timesheet timesheet = _timesheetRepository.GetTimesheet(timesheetId);
        Helpers.ErrorHandler check = new Helpers.ErrorHandler();
        check.write("can I validate immediately? :- ", TryValidateModel(timesheet).ToString());
开发者_如何学C        check.write("can I save immediately? :- ", TryUpdateModel(timesheet).ToString());

TryValidateModel - returns true TryUpdateModel - returns false

Any recommendations?


Validation and binding are different. Invalid data can often be bound (this is a feature; it makes re-displaying a page in the case of an error much easier), and "valid" (per your validation rules, if any) data sometimes can't be bound, due to typing conflicts.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜