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

How to highlight controls on validation error

11 Answers 292 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Christoph
Top achievements
Rank 1
Christoph asked on 26 Oct 2010, 08:35 AM
Dear Telerik Support,

when I enter an invalid value into one of your controls like IntegerTextBox or DatePicker, the control is highlighted in red. But when I do some custom validation on my view model (e.g. date begin is after date end) after a submit, I only get the validation message. The control itself is not highlighted.

My control at the aspx web site looks like this:

<%: Html.LabelFor(model => model.Startdate)%>
<%= Html.Telerik().DatePickerFor(model => model.Startdate) %>
<%: Html.ValidationMessageFor(model => model.Startdate, "*", new { Class = "field-validation-error star-error" })%>

and I do some custom validations like this in my controller:

if (ViewModel.Startdate != null && ViewModel.Enddate != null)
{
     if (ViewModel.Startdate > ViewModel.Enddate)
            ModelState.AddModelError("Startdate", <ErrorMessage>);
 }

return View(ViewModel);

After that, the errors are displayed correctly, but the telerik controls are not highlighted in red. When I do the same for controls from Html namespace like Html.TextBox(), the controls are highlighted in red after the validation error is added to the ModelState.

Is there a way to highlight the controls after validation errors? Because I am using your controls and controls from Html namespace and the validation results should look the same for all controls.

Kind regards,

Christoph

11 Answers, 1 is accepted

Sort by
0
Christian
Top achievements
Rank 1
answered on 05 Aug 2011, 09:56 PM
Can we have an answer on this one please?

Thanks
Christian
0
Alexandre Jobin
Top achievements
Rank 1
answered on 16 Aug 2011, 12:29 AM
i also need an answer for this question.

i have attached a screenshot of the problem. What i can see is when we enter en invalid value, telerik will put his own error validation class named "t-state-error". But if we just want to valide a required field, nothing happen on this field.

Is there a reason why we can't get the original behaviour of MVC3 who use the "input-validation-error" class when a field is not valid, whatever the validation is? It would be much more easy for everyone!

Check the screenshot!
0
Alexandre Jobin
Top achievements
Rank 1
answered on 22 Aug 2011, 03:17 PM
hi Telerik Support!

i know that you have the right to not answer all the questions on the forum but i really need to know what you are trying to do with the validation for your controls.

  • Is it a bug that your controls don't get the MVC standard class "input-validation-error" when there's an error on it?
  • or maybe you are replacing it with your own validation class "t-state-error"? if its the case, is it normal that we don't get this error class on an empty required field error?

since that a form can have basic input fields and also Telerik input fields, i think it would be a good idea to use the "input-validation-error" class on your controls. That way, we don't have to play with sometimes "t-state-error" and sometimes "input-validation-error"!

thank your for your reading!

alex
0
Georgi Krustev
Telerik team
answered on 23 Aug 2011, 08:20 AM
Hello Alexandre,

 
This is a known issue which I am glad to inform will be addressed in the next release of Telerik Components for ASP.NET MVC. The input components will behave like ASP.NET MVC input helpers. In other words on error will render Html.ValidationInputCssClassName.

Kind regards,
Georgi Krustev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Alexandre Jobin
Top achievements
Rank 1
answered on 23 Aug 2011, 01:38 PM
great! this is a good news!

thank you Georgi for this information!

alex
0
Luis
Top achievements
Rank 1
answered on 11 Oct 2011, 02:55 AM
I'm also waiting for it ...
0
Alexandre Jobin
Top achievements
Rank 1
answered on 11 Oct 2011, 01:28 PM
this is supposed to be fixed in the 2011 Q2 SP1 release
0
Georgi Krustev
Telerik team
answered on 11 Oct 2011, 01:35 PM
Hello Alexandre Jobin,

 
Yes it is supported. Check this demo. The component renders "input-validation-error" when model state error occurs.

Regards,
Georgi Krustev
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
yang
Top achievements
Rank 1
answered on 30 Nov 2011, 06:30 AM
I am using Telerik_ASPNET_MVC_2011_2_712_OpenSource.msi in my Orchard Solution.

however, the with validation error, the auto_complete or datepicker are not highlighed still.

everything else working just fine.

could you tell me how to fix it ???

thanks
0
yang
Top achievements
Rank 1
answered on 30 Nov 2011, 06:33 AM
hi, mate

I use the download Telerik_ASPNET_MVC_2011_2_712_OpenSource.msi

still have the validation error.   could you tell me what versions that you fix the problem?
0
Alexandre Jobin
Top achievements
Rank 1
answered on 30 Nov 2011, 02:46 PM
hi yang!

it have been corrected in the Q2 2011 SP1 (v2011.2.914)!

alex
Tags
General Discussions
Asked by
Christoph
Top achievements
Rank 1
Answers by
Christian
Top achievements
Rank 1
Alexandre Jobin
Top achievements
Rank 1
Georgi Krustev
Telerik team
Luis
Top achievements
Rank 1
yang
Top achievements
Rank 1
Share this question
or