From my own experience it appears that the controls don't but I am unsure if I am missing a setting or if this is a "work in progress" for a future release. Specifically I am looking at the NumericTextBox controls. I noticed that they don't output any of the data-val* attributes and as such don't honor the default Required validations or any custom validations. We are currently using the 2011.1.414 build.
5 Answers, 1 is accepted
The build which you are using fully supports unobtrusive validation and renders those attributes. Make sure UnobtrusiveValidation is enabled in your web.config though.
Greetings,Atanas Korchev
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!
I did find that if I changed my implementation from:
@(Html.Telerik().CurrencyTextBoxFor(model => model.LoanAmount).Spinners(false).DecimalDigits(0).EmptyMessage("$"))@(Html.Telerik().CurrencyTextBoxFor(model => model.LoanAmount).Spinners(false).DecimalDigits(0).EmptyMessage("$").InputHtmlAttributes(Html.GetUnobtrusiveValidationAttributes("LoanAmount")))Then the attributes appeared just fine. Even when I was debugging in ViewComponentExtensions.GetUnobtrusiveValidationAttributes() I tried variations on the name that was passed into the method and wasn't able to get any of them to come back with data.
EDIT: I attached my sample project. If you run it and go to /Account/Register and view source or press the register button you can see that the first Age field doesn't get marked with the Required message but the second one does.
Thank you for the test project.
This actually is a known issue, which happens when the Model is null.
This code:
return View();HenceViewComponentExtensions.GetUnobtrusiveValidationAttributes() method is not able to get correct data validation attributes.
In order to overcome this issue I will suggest you return empty RegisterModel:
return View(new RegisterModel());Georgi Krustev
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!
Thank you for the updated test project.
The NumericTextBox, as other UI components which support unobtrusive validation, uses Html.ViewContext.ViewData rather then Html.ViewData, which causes the aforementioned issue.
We will try to address this issue for the SP1 Q2 2011 release of Telerik Extensions for ASP.NET MVC.
For now, you can continue to use the InputHtmlAttributes method to apply unobtrusive validation attributes.
As a token of gratitude for your involvement I have updated your Telerik points.
Georgi Krustev
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!