<tr><tdstyle="width:20%">Max speed</td><tdstyle="width:15%">@((ViewBag.Vehicle1Selected as IEnumerable<Plane>).FirstOrDefault().MaxSpeed)</td><tdstyle="width:15%">@((ViewBag.Vehicle2Selected as IEnumerable<Plane>).FirstOrDefault().MaxSpeed)</td><tdstyle="width:15%">@((ViewBag.Vehicle3Selected as IEnumerable<Plane>).FirstOrDefault().MaxSpeed)</td><tdstyle="width:15%">@((ViewBag.Vehicle4Selected as IEnumerable<Plane>).FirstOrDefault().MaxSpeed)</td></tr>
This is a table in the browser
I want to make green bg highlighting cells with max value (for example 600), red highlighting with min value and no highlighting to cells between max and min. How to make it, with taghelper or view component?
(without AJAX if it possible)
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
1 Points
1 Post
Highlighting table cell depending of value
Mar 09, 2020 10:09 PM|BogdanIlkiv|LINK
I have a controller, he takes four values from four dropdowns (vehicle1, vehicle2, etc) and returns selected value to ViewBag.
View shows data from ViewBag like this
This is a table in the browser
Contributor
2070 Points
606 Posts
Re: Highlighting table cell depending of value
Mar 10, 2020 06:38 AM|Sherry Chen|LINK
Hi BogdanIlkiv,
I guess there is no taghelper that can achieve this effect directly. If you don't want to use js, you can do this as follows:
Controller , use ViewBag to get the MaxSpeed and MinSpeed
View
Result:
Best Regard,
Sherry
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.