Hi, I wonder if anyone can help with this simple little problem. I am relitively new to CSLA and dot net, so forgive my ignorance!
I have a simple windows form which is essentially a maintenance form for a business object. My problem is that if I dont enter any data in a field, the validation rules are not triggered even though there are authorisation rules in the business object. In this instance its just a CommonRules.StringRequired rule, as the field cannot be empty.
If however, I enter some text and then delete it again, the rule is triggered and the error provider displays the appropriate warning icon.
Ideally when I try to Save the data to the business object I would like the validation rules to fire and identify any fields that contain invalid ( or empty ) data.
I'm sure this is really easy, but I dont know how to do it...!?
Any help would be gratefully received...
Many thanks,
Nick
Thanks for the advice, and you were correct about the setting of the data source update mode. I have now changed this to OnPropertyChanged, however the problem is still persisting...
Any other suggestions would be most welcome...
Thanks,
Nick
Hi Herman,
Thanks, that certainly helps me out. Everytime I create a new record, I now see the form controls placed into their error state right from the start. Do you know if there is anyway that I could expose the call to ValidationRules.CheckRules() as a public method on the business object ? I could then call something like _boCustomer.CheckRules() as part of the forms Save() method code. This in turn would ensure that the _boCustomer.IsValid flag is set correctly and I can then pick up on this during the save method code.
By the fact that this functionality isn't there probably means my thinking is wrong, but it would seem useful to be able to trigger this as part of my Save() method code.
Thanks,
Nick
Yes, I would agree on that one Herman.
How about I put a call to ValidationRules.CheckRules() within my DataPortal_Update() and DataPortal_Insert() methods. I could then throw an exception if any of the data is invalid. Does that make sense...?
Thanks,
Nick
Copyright (c) Marimer LLC