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

Rating Items ImageURL

1 Answer 98 Views
Rating
This is a migrated thread and some comments may be shown as answers.
eric
Top achievements
Rank 1
eric asked on 12 Apr 2012, 05:21 PM
All the standard ASP.net controls that have a ImageURL property accept relative urls (ex. ~/img/image.gif)

When I place a relative URL into a Rad Rating Item, it doesn't resolve the URL, it simply embeds this as a literal value to the page's CSS.

<telerik:RadRatingItem CssClass="ratingItem" Value="1" ImageUrl="~/img/ratings/rating_1_normal.png" ToolTip="Very Easy" SelectedImageUrl="~/img/ratings/rating_1_selected.png" HoveredImageUrl="~/img/ratings/rating_1_hover.png" />

I can adjust the URL's accordingly by removing the ~/ and change it to an absolute path, however when published to a server sometimes the path is a little different. This results in the images not displaying because the CSS is pointing to the wrong place.  Is this by design?

I used this code to resolve the URLs so that I could use relative paths in the image URL properties:
If String.IsNullOrEmpty(item.ImageUrl) = False Then
              If item.ImageUrl.StartsWith("~/") Then
                  item.ImageUrl = ResolveUrl(item.ImageUrl)
              End If
          End If
          If String.IsNullOrEmpty(item.SelectedImageUrl) = False Then
              If item.SelectedImageUrl.StartsWith("~/") Then
                  item.SelectedImageUrl = ResolveUrl(item.SelectedImageUrl)
              End If
          End If
          If String.IsNullOrEmpty(item.HoveredImageUrl) = False Then
              If item.HoveredImageUrl.StartsWith("~/") Then
                  item.HoveredImageUrl = ResolveUrl(item.HoveredImageUrl)
              End If
          End If
          If String.IsNullOrEmpty(item.HoveredSelectedImageUrl) = False Then
              If item.HoveredSelectedImageUrl.StartsWith("~/") Then
                  item.HoveredSelectedImageUrl = ResolveUrl(item.HoveredSelectedImageUrl)
              End If
          End If

Is there ever going to be an implementation of allowing relative paths in the image URL fields?

1 Answer, 1 is accepted

Sort by
0
Niko
Telerik team
answered on 13 Apr 2012, 01:49 PM
Hello Eric,

 The RadRating items are working by default in this mode. Still you can use the ResolveUrl or ResolveClientUrl and assign the resolved paths to the ImageUrl property of each item on the server side. An example follows:
theRating.Items[0].ImageUrl = ResolveClientUrl("~/content/testImages/logo.png");

Hope this helps.

Greetings,
Niko
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 RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Rating
Asked by
eric
Top achievements
Rank 1
Answers by
Niko
Telerik team
Share this question
or