public static bool ValidateSave(Page p, ValidateHandler vh, object obj, NoticeLabel msg, string noticeText, string cssErrInput, Action callback) { var ctx = ModelContext.GetInstance(obj.GetType()); EnumControls(p, ctx.Info, delegate(MemberHandler mh, WebControl c) { c.CssClass = ""; }); vh.ValidateObject(obj); if (vh.IsValid) { callback(); if (msg != null) { msg.AddNotice(noticeText); } } else { foreach (string str in vh.ErrorMessages.Keys) { if (msg != null) { msg.AddWarning(vh.ErrorMessages[str]); } WebControl c = GetWebControl(p, ctx.Info, str); if (c != null) { c.CssClass = cssErrInput; } } } return(vh.IsValid); }
public static bool ValidateSave(Page p, ValidateHandler vh, IDbObject obj, NoticeLabel msg, string noticeText, string cssErrInput) { return(ValidateSave(p, vh, obj, msg, noticeText, cssErrInput, () => DbEntry.Save(obj))); }
public static bool ValidateSave(Page p, IDbObject obj, NoticeLabel msg, string noticeText) { var vh = new ValidateHandler(); return(ValidateSave(p, vh, obj, msg, noticeText, "ErrInput")); }