Last post Dec 08, 2010 11:23 AM by subong
Nov 19, 2008 09:57 AM|itay.basoni|LINK
I have the following code:
partial void OnValidate(System.Data.Linq.ChangeAction action)
if (action == ChangeAction.Delete)
MyDataContext dc = new MyDataContext();
int amount = (from l in dc.Links
where l.Parent == this.Id
if (amount > 0)
throw new ValidationException("Unable to delete a parent object, delete the children first");
The exception is displayed in the regular yellow screen !
Any ideas ?
Nov 19, 2008 10:26 AM|rtpHarry|LINK
Here is one approach to displaying the exceptions:
Here is a better one:
Nov 19, 2008 11:20 AM|itay.basoni|LINK
In Dynamic-Data projects exceptions are being displayed automatically in the validation summary control, atleast should be displayed automatically.
Does anyone know whether I should set something in the configuration to enable this type of behavior ?
Nov 19, 2008 12:16 PM|sjnaughton|LINK
I would try the OnValidate in a new scaffolded project to see if it's something in your current project. I done as you have an it appears in the ValidationSummary as it should.
Also Make sure you are running Dynamic Data that comes with VS2008 SP1. if your project is originally from an earlier release then I would start a new.
Nov 19, 2008 01:56 PM|itay.basoni|LINK
I did all of that and still nothing .. I even removed the MVC preview i had installed just to be certain.
I'll try to reinstall the framework and perhaps also the V.S during this weekend ... it must be a problem with the references.
The funny thing is - it worked on the preview version !
Thanks anyway, I appreciate your help.
Nov 19, 2008 05:15 PM|davidebb|LINK
We actually saw this issue before, or something similar. Could you try making the following change in the page template:
OnClientClick='return confirm("Are you sure you
want to delete this item?");'
See this thread for reference.
Nov 22, 2008 02:36 PM|itay.basoni|LINK
Thank you, it's finally working :)
The code I've written handles the SQLException - "DELETE failed because of FOREIGN KEY constraint".
I think, and I'm sure you'd agree, this exception should be automatically handled by Linq or DynamicData.
Thanks again for the great help you've given.
Nov 22, 2008 11:14 PM|ricka6|LINK
Yes we agree. It will be fixed in the next version.
Dec 08, 2010 07:29 AM|subong|LINK
I Have the same problem with ListDetails.aspx. (vs2008 sp1, asp.net3.5 sp1)
Is it posible to set CausesValidation property?.
Dyanamic Data Web Site
Dec 08, 2010 08:27 AM|sjnaughton|LINK
Hi subong, yes it is but you will have to add the relavent button to the GridView like in the List page.
Dynamic Data 4
Dec 08, 2010 11:23 AM|subong|LINK
I will try this. Thanks so much.
ASP.NET Dynamic Data