I have a page here with a few list views on it that are all bound to Linq data sources and they seem to be working just fine.
I want to add validation such that when a checkbox (IsVoid on the object) is checked, comments must be entered (VoidedComments on the object).
Here's the bound object's OnValidate method:
partial void OnValidate(ChangeAction action)
{
if (action == ChangeAction.Update)
{
if (_IsVoid)
{
string comments = this.VoidedComments;
if (string.IsNullOrEmpty(this._VoidedComments))
{
throw new ValidationException("Voided Comments are Required to Void开发者_如何学编程 an Error");
}
}
}
}
Despite there being a dynamic validator on the page referencing the same ValidationGroup as the dynamic control, when the exception fires, it's caught in JavaScript and the debugger wants to break in. The message is never delivered to the UI as expected.
Any thoughts as to What's going on?
I think I found the answer here:
http://forums.asp.net/t/1476131.aspx
http://blogs.msdn.com/b/davidebb/archive/2008/12/11/handling-database-exceptions-in-dynamic-data.aspx
We will have to use a new ImprovedDynamicValidator for DD4 and ASP.NET 4.
精彩评论