This question is locked. New answers and comments are not allowed.
Monah Abou Hattoum
Top achievements
Rank 1
Monah Abou Hattoum
asked on 08 Nov 2011, 09:13 AM
Hi,
i am experienced a strange problem with the Grid and Validation Summary
here the scenario:
1- i have a Grid to display the car details
2- user can edit the details in Popup mode
3- i want to display the validation errors in Validation Summary and not Validation Message
4- i am using IValidatableObject to validate the user inputs and CustomValidation
problem:
1- if i made the built in attribute validation, then the validation summary displays the errors correctly
2- if i made custom validation, validation summary fails to display but surround the field by red ref: (ViewModels.CustomValidator for car type field)
3- if errors return by the Validate function, validation summary fails to display ref: (ViewModels.Car for country field)
problem facing:
1- try to set the country on edit to N/A and click update, nothing will be displayed however ModelState.IsValid is false
2- try to set the car type on edit to N/A and click update, the field will be red but no displayed message in the validation summary
3- try to clear the Name field and click update, the field will be red and validation summary will be displayed correctly
I am not able to figure out why validation summary not displaying in all cases, and how to fix this please?
thanks in advance
i am experienced a strange problem with the Grid and Validation Summary
here the scenario:
1- i have a Grid to display the car details
2- user can edit the details in Popup mode
3- i want to display the validation errors in Validation Summary and not Validation Message
4- i am using IValidatableObject to validate the user inputs and CustomValidation
problem:
1- if i made the built in attribute validation, then the validation summary displays the errors correctly
2- if i made custom validation, validation summary fails to display but surround the field by red ref: (ViewModels.CustomValidator for car type field)
3- if errors return by the Validate function, validation summary fails to display ref: (ViewModels.Car for country field)
problem facing:
1- try to set the country on edit to N/A and click update, nothing will be displayed however ModelState.IsValid is false
2- try to set the car type on edit to N/A and click update, the field will be red but no displayed message in the validation summary
3- try to clear the Name field and click update, the field will be red and validation summary will be displayed correctly
I am not able to figure out why validation summary not displaying in all cases, and how to fix this please?
thanks in advance
6 Answers, 1 is accepted
0
Monah Abou Hattoum
Top achievements
Rank 1
answered on 09 Nov 2011, 07:18 PM
please any tip or help?
0
Hello Monah Abou Hattoum,
You need to return the member name of the field which validation fails. I.e:
Showing server validation errors in validation summary should be handled manually by handling OnError grid client event.
Greetings,
Nikolay Rusev
the Telerik team
You need to return the member name of the field which validation fails. I.e:
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext){ // here i am trying to validate Country not using the custom validator if (Country == "N/A") yield return new ValidationResult("Country filed is required!", new[] { "Country" });}Showing server validation errors in validation summary should be handled manually by handling OnError grid client event.
Greetings,
Nikolay Rusev
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
0
Monah Abou Hattoum
Top achievements
Rank 1
answered on 13 Nov 2011, 12:58 PM
Greetings,
thanks for the reply,
i wanted to know how to use the validaiton summary in this situation.
i solved this issue by adding ValidationMessageFor at the top of the custom editor and it worked for me
thanks for the tip regarding the ivalidatableobject
best regards
thanks for the reply,
i wanted to know how to use the validaiton summary in this situation.
i solved this issue by adding ValidationMessageFor at the top of the custom editor and it worked for me
thanks for the tip regarding the ivalidatableobject
best regards
0
Hello Monah Abou Hattoum,
Client representation of the validation summary looks as follow:
You will have to manually insert li elements for error handled on grid OnError.
Greetings,
Nikolay Rusev
the Telerik team
Client representation of the validation summary looks as follow:
<div data-valmsg-summary="true" class="validation-summary-valid"> <ul> <li style="display:none"></li> </ul></div>You will have to manually insert li elements for error handled on grid OnError.
Greetings,
Nikolay Rusev
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
0
Venkata
Top achievements
Rank 1
answered on 13 Apr 2012, 02:38 PM
HI Nikolay ,
Even I am facing the problem of writing into Validation div List . Could you please give a sample code ?
so that it will be helpful to us.
Thanks and Regards,
Venkat
Even I am facing the problem of writing into Validation div List . Could you please give a sample code ?
so that it will be helpful to us.
Thanks and Regards,
Venkat
0
Monah Abou Hattoum
Top achievements
Rank 1
answered on 14 Apr 2012, 09:25 AM
Greetings,
if you want a fast solution, based on the attachement i added early in the question
please follow these steps
1- at the top of the car partial view add these
@Html.ValidationMessage("Country")
@Html.ValidationMessage("Name")
@Html.ValidationMessage("Model")
@Html.ValidationMessage("Weight")
@Html.ValidationMessage("Type")
and no need to use the validation summary
2- in the ViewModels->Car.cs
add the missing part in the return statement as "Nikolay Rusev" said in his reply
regards,