This is a migrated thread and some comments may be shown as answers.

[Solved] Model validation on Tab

3 Answers 157 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jeroen Eikmans
Top achievements
Rank 1
Jeroen Eikmans asked on 13 Sep 2011, 10:10 AM
Hello,

I have an application with some sort of master-detail editform.
On the left is a treeview and when you select an item, on the right-side there will be a tabstrip. On each tab the user can modify some data.

The model used to modify the data has several attributes like Required and StringLength on it's properties.
In the "model modify view" i use the Html.TextBoxFor and Html.ValidationMessageFor methods.
But i'm not able to get the client-side validation working. When i open this view directly in IE or FF the validation is working but when the view is displayed within a tab the validation isn't there.

The last couple of days I've tried a lot of different pieces of code to get the client-side validation working but so far no luck.
I also tried the solution presented in http://www.telerik.com/community/forums/aspnet-mvc/tabstrip/form-validation-does-not-work-with-multiple-tabs.aspx but jQuery.validator is always Undefined (???)
Also the solution "Sys.Mvc.FormContext._Application_Load();" in all my PartialViews did not do the trick.

I've attached a demo-app demonstrating this behaviour.
Can somebody have a look at it and tell me what i'm doing wrong?
Thanks in advance!

3 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 13 Sep 2011, 04:40 PM
Hi Roel Martens,

In order validation to work in your scenario you should initialize it when the form is loaded as mentioned in the thread you have pointed. I have attached an updated version of your project.

All the best,
Rosen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jeroen Eikmans
Top achievements
Rank 1
answered on 21 Sep 2011, 04:07 PM
Hello,

I have another question about using AddModelError. Perhaps not a Telerik specific issue but i'm not sure what I still need to implement to get it working.
In the UserDetails Post-method I added : ModelState.AddModelError("""This is my custom error");

As far as I know (and could find on google) AddModelError with empty string as key should make the Html.ValidationSummary display the errormessage on the client. But I can't get this to work...

I attached an updated demo-app with this code.
If anybody could have a look and tell me what i have not implemented, would be very appreciated!
0
Accepted
Rosen
Telerik team
answered on 22 Sep 2011, 05:08 PM
Hello Roel Martens,

Looking at the sample you have sent us it seems that ajax form is not correctly configured. You should set UpdateTargetId in order ajax form to update the page and show the server side errors.

All the best,
Rosen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
TabStrip
Asked by
Jeroen Eikmans
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Jeroen Eikmans
Top achievements
Rank 1
Share this question
or