I would like to attach an error class to the label and input when Html.ValidationMessageFor has an error string. Is there a good way to do this with razor?
An error class is already automatically attached to the inputfield when it is in error, but not to the label. No easy way to change the style of the label of an element in error.
GorillaMann
Member
117 Points
332 Posts
Razor manipulation conditional when Html.ValidationMessageFor( has data
Dec 15, 2012 06:29 PM|LINK
I would like to attach an error class to the label and input when Html.ValidationMessageFor has an error string. Is there a good way to do this with razor?
<div class="row collapse"> <div class="twelve columns">@Html.ValidationMessageFor(m => m.CompanyName)</div> <div class="two columns"><label class="inline">Company Name</label></div> <div class="ten columns">@Html.EditorFor(m => m.CompanyName)</div> </div>RameshRajend...
Star
7983 Points
2099 Posts
Re: Razor manipulation conditional when Html.ValidationMessageFor( has data
Dec 15, 2012 06:58 PM|LINK
Ya good.But u can use validationsummary
http://www.c-sharpcorner.com/blogs/5196/html-validationsummary-in-asp-net-mvc-3.aspx
francesco ab...
All-Star
20912 Points
3279 Posts
Re: Razor manipulation conditional when Html.ValidationMessageFor( has data
Dec 16, 2012 10:23 AM|LINK
An error class is already automatically attached to the inputfield when it is in error, but not to the label. No easy way to change the style of the label of an element in error.
Mvc Controls Toolkit | Data Moving Plug-in Videos