4 Answers, 1 is accepted
0
Hello Matt,
Daniel
the Telerik team
The attributes will not be added if an actual instance of the model is not passed to the view. If this is not causing the problem in your scenario, I will need a sample project or the code you are using so I can check the setup.
Regards,Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Matt
Top achievements
Rank 1
answered on 04 Jul 2012, 06:06 PM
Hi Daniel,
Thanks for your reply. This problem only appears to occur when using editor templates for complex nested models. I've attached a completely stripped down project (even the Kendo css and js is not applied) containing an example view that exhibits this behaviour. The second Kendo rendered TextArea has no data validation attributes applied. The problem appears to occur in the Mvc Extensions at the point that the ViewComponentExtensions.GetUnobtrusiveValidationAttributes method is called. For some reason in the case of the example project that method is not returning any attributes (maybe the view model property names or field prefix are passed incorrectly?). Note that if you use a standard Html.TextAreaFor() as I have for the first text area it works as expected, leaving me to suspect that this is indeed a problem with the Kendo extensions.
In addition, this appears to be a problem with any control that is rendered in a nested view - not just the editor.
Thanks for your reply. This problem only appears to occur when using editor templates for complex nested models. I've attached a completely stripped down project (even the Kendo css and js is not applied) containing an example view that exhibits this behaviour. The second Kendo rendered TextArea has no data validation attributes applied. The problem appears to occur in the Mvc Extensions at the point that the ViewComponentExtensions.GetUnobtrusiveValidationAttributes method is called. For some reason in the case of the example project that method is not returning any attributes (maybe the view model property names or field prefix are passed incorrectly?). Note that if you use a standard Html.TextAreaFor() as I have for the first text area it works as expected, leaving me to suspect that this is indeed a problem with the Kendo extensions.
In addition, this appears to be a problem with any control that is rendered in a nested view - not just the editor.
0
Hello Matt,
Regards,
Daniel
the Telerik team
Thank you for providing a sample project. The problem occurs because the meta data from which the attributes can be obtained is different in this context. I am glad to inform you that this has been fixed and the changes will be applied in the official release of Kendo UI for ASP.NET MVC.
For now you can use the HtmlAttributes method to set the validation attributes e.g.
@Html.Kendo().EditorFor(x => x.Test2).HtmlAttributes(Html.GetUnobtrusiveValidationAttributes(
"Test2"
))
Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Matt
Top achievements
Rank 1
answered on 05 Jul 2012, 11:28 AM
Thanks Daniel, that's great news. As a side note it might also be worth checking this for the standard Telerik MVC extensions, as I could reproduce it with those last time I checked.