Just to throw another spanner in the ValidationGroup works.....
I'm trying to setup some nice AJAX editing / inserting for lookup values within a master record - click "Add New" to create a new master record....Choose a lookup item from a dropdown, but the item you want isn't there. Rather than click cancel, go to the
lookup table, click add, enter the item, click save, then go back to your master record and click "Add New" again............I wanted the ability to simply add a new lookup item from within the add-new page of the master record.
I'm doing this using the AJAX Web Toolkit modal popup. I've got a panel which contains a detailsview, autogenerated validationgroupdynamicfields and another datasource. The "add" works fine, except I can't get the validation working properly
I've followed this thread and setup a ValidationGroupDynamicField, modified my AutoFieldGenerator to use it and that all looks good. However, for some reason the validators in my modal-popup panels are being written to the page with enabled=0, so they are
ignored when the "Save" button is clicked.....The server-side validation still fires, so invalid records aren't saved, but I don't get any errors - it just exits the panel.
I've tried the ListDetails page using the modal popup from the Futures project and I that works fine with validation.....
Ugh. I seem to always post these things just before I discover the answer......
Two issues in play here.....
1. I didn't have a "Required" attribute on my lookup field's description column. I only had a StringLength attribute with min and max lengths
2. In my server Save_Click event, I was validating the page, but only hiding the modal popup if everything was valid - I needed to SHOW it again if it wasn't valid!
So, The reason the validator had enabled=0 was because I didn't have a RequiredAttribute.
And the reason I wasn't getting any error message was because when it was failing the string-length validation (Which is on the server, not the client) I wasn't showing the modal panel again......
Everything is now hunky dory! Thanks a lot for this thread.
scothu
Participant
1424 Points
290 Posts
AspNetTeam
Microsoft
Moderator
Re: Setting ValidationGroup on DynamicValidator and DynamicControl has no effect
Jan 19, 2009 04:54 PM|LINK
We are adding ValidationGroup to the DynamicField in the next version of Dynamic Data based on your guys feedback.
PM, ASP.NET Team, Microsoft
sjnaughton
All-Star
25698 Points
5169 Posts
MVP
Re: Setting ValidationGroup on DynamicValidator and DynamicControl has no effect
Jan 19, 2009 07:03 PM|LINK
Thanks Scott [:D]
Dynamic Data Validation Groups
Always seeking an elegant solution.
DaveRuss
Participant
801 Points
172 Posts
Re: Setting ValidationGroup on DynamicValidator and DynamicControl has no effect
Mar 13, 2009 09:29 AM|LINK
Just to throw another spanner in the ValidationGroup works.....
I'm trying to setup some nice AJAX editing / inserting for lookup values within a master record - click "Add New" to create a new master record....Choose a lookup item from a dropdown, but the item you want isn't there. Rather than click cancel, go to the lookup table, click add, enter the item, click save, then go back to your master record and click "Add New" again............I wanted the ability to simply add a new lookup item from within the add-new page of the master record.
I'm doing this using the AJAX Web Toolkit modal popup. I've got a panel which contains a detailsview, autogenerated validationgroupdynamicfields and another datasource. The "add" works fine, except I can't get the validation working properly
I've followed this thread and setup a ValidationGroupDynamicField, modified my AutoFieldGenerator to use it and that all looks good. However, for some reason the validators in my modal-popup panels are being written to the page with enabled=0, so they are ignored when the "Save" button is clicked.....The server-side validation still fires, so invalid records aren't saved, but I don't get any errors - it just exits the panel.
I've tried the ListDetails page using the modal popup from the Futures project and I that works fine with validation.....
What am I missing?
Validation
DaveRuss
Participant
801 Points
172 Posts
Re: Setting ValidationGroup on DynamicValidator and DynamicControl has no effect
Mar 13, 2009 10:23 AM|LINK
Ugh. I seem to always post these things just before I discover the answer......
Two issues in play here.....
1. I didn't have a "Required" attribute on my lookup field's description column. I only had a StringLength attribute with min and max lengths
2. In my server Save_Click event, I was validating the page, but only hiding the modal popup if everything was valid - I needed to SHOW it again if it wasn't valid!
So, The reason the validator had enabled=0 was because I didn't have a RequiredAttribute.
And the reason I wasn't getting any error message was because when it was failing the string-length validation (Which is on the server, not the client) I wasn't showing the modal panel again......
Everything is now hunky dory! Thanks a lot for this thread.
Kyle.Savant
Member
2 Points
12 Posts
Re: Setting ValidationGroup on DynamicValidator and DynamicControl has no effect
Oct 26, 2009 04:36 PM|LINK
Scott,
Has this feature been added yet? Thanks!
Visit my blog: DevelopThis.Net
hennehelene
Member
4 Points
2 Posts
Re: Setting ValidationGroup on DynamicValidator and DynamicControl has no effect
Nov 09, 2009 02:01 PM|LINK
I'm looking for the reply aswell, and found that it is a new property on DynamicField in the 4.0 version
http://msdn.microsoft.com/en-us/library/system.web.dynamicdata.dynamicfield_properties(VS.100).aspx