Skip to content

Commit dd9a1c7

Browse files
KB BotJekata
authored andcommitted
Added new kb article how-to-display-labels-on-rating-stars-radrating
1 parent 41665f7 commit dd9a1c7

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
title: Displaying Labels on Rating Stars in RadRating Control
3+
description: Learn how to show labels above each star in the RadRating control to indicate their value using CSS and the title attribute.
4+
type: how-to
5+
page_title: How to Display Value Labels on Stars with RadRating for ASP.NET AJAX
6+
slug: how-to-display-labels-on-rating-stars-radrating
7+
tags: radrating, asp.net ajax, css, labels, stars, value display
8+
res_type: kb
9+
ticketid: 1671751
10+
---
11+
12+
## Environment
13+
14+
<table>
15+
<tbody>
16+
<tr>
17+
<td>Product</td>
18+
<td>RadRating for ASP.NET AJAX</td>
19+
</tr>
20+
<tr>
21+
<td>Version</td>
22+
<td>all</td>
23+
</tr>
24+
</tbody>
25+
</table>
26+
27+
## Description
28+
I want to use the [RadRating](https://docs.telerik.com/devtools/aspnet-ajax/controls/rating/overview) control but need to display a label showing the value of each star. This KB article also answers the following questions:
29+
- How can I show the value of each rating star in the RadRating control?
30+
- Is it possible to display labels above stars in the RadRating control?
31+
- Can I customize the appearance of labels on rating stars in the RadRating control?
32+
33+
## Solution
34+
To display a label for each star in the RadRating control, utilize the title attribute of each rating item. CSS can be used to show the value of each star above it. Here's a step-by-step guide on achieving this:
35+
36+
1. Apply the following CSS to display the value of the title attribute above each star:
37+
38+
```css
39+
.RadRating {
40+
padding-top: 20px;
41+
}
42+
43+
.RadRating .rrtItem a::after {
44+
content: attr(title);
45+
position: absolute;
46+
top: -15px;
47+
display: block;
48+
width: 24px;
49+
text-align: center;
50+
}
51+
```
52+
53+
2. Add the RadRating control to your page and specify the Title attribute for each RadRatingItem:
54+
55+
```aspx
56+
<telerik:RadRating RenderMode="Lightweight" ID="RadRating2" runat="server" ItemCount="5" Value="3">
57+
<Items>
58+
<telerik:RadRatingItem Value="1" Title="1"></telerik:RadRatingItem>
59+
<telerik:RadRatingItem Value="2" Title="2"></telerik:RadRatingItem>
60+
<telerik:RadRatingItem Value="3" Title="3"></telerik:RadRatingItem>
61+
<telerik:RadRatingItem Value="4" Title="4"></telerik:RadRatingItem>
62+
<telerik:RadRatingItem Value="5" Title="5"></telerik:RadRatingItem>
63+
</Items>
64+
</telerik:RadRating>
65+
```
66+
67+
This setup ensures that the value of each star is displayed above it, providing a clear visual indicator of the rating value. You can customize the CSS to fit your design requirements, such as adjusting the font size, color, or positioning of the labels.
68+
69+
## See Also
70+
- [RadRating Overview](https://docs.telerik.com/devtools/aspnet-ajax/controls/rating/overview)
71+
- [CSS ::after Pseudo-element](https://developer.mozilla.org/en-US/docs/Web/CSS/::after)

0 commit comments

Comments
 (0)