Last post Nov 22, 2012 08:32 PM by Decker Dong - MSFT
Nov 05, 2012 04:15 AM|Yannick86|LINK
In the context_SavingChanges method of my partial metadata class I am doing custom validations which throw a ValidationException.
Now it occurs to me that when this validationException is thrown it resets all the form fields.
When I however use for example the Required attribute on a field and I do not fill it on on purpose it will show the errorMessage that I gave the attribute, but it does not clear the form fields.
Anyone got an idea?
Thanks in advance,
Nov 05, 2012 08:17 PM|Decker Dong - MSFT|LINK
If necessary, please show us your codes.
Nov 06, 2012 05:58 AM|sjnaughton|LINK
Hi Yannick, I'm sure the reason they get reset when you throw a validation exception in the data model is because the page gets a full refresh. But the reason the do not get reset with the required field and any of the other standard validators is because
the validation is being run on the client.
There may be a way to pass the entity values back to the page in the exception somehow, but I'm not sure.
Nov 08, 2012 09:13 AM|Yannick86|LINK
Good to see you're still on this forum :)
Do you have any sample on how this is normally done?
Kind regards and thanks in advance,
Nov 08, 2012 06:06 PM|sjnaughton|LINK
Hi Yannick, I'm thinking :)
Nov 22, 2012 04:22 AM|Yannick86|LINK
Hey Steven, still thinking? ;P :D
Nov 22, 2012 05:41 AM|sjnaughton|LINK
I still can't think of a way of doing this sorry.
Nov 22, 2012 08:32 PM|Decker Dong - MSFT|LINK
Or just use attributes applied on the public properties, or write your own methods to be instead of partial methods.