Link to home
Start Free TrialLog in
Avatar of obautista
obautista

asked on

AJAX Rating Control in ListView Control

I am using the AJAX Rating Control inside a ListView control.  I am creating a Rating Control for X number of records in my datasource.  The Rating Control is being created as expected, but not behaving correctly.  It only works on the first ListView record created.  When I hover over the stars in the first record, they change colors as expected.  The first record also posts back when I click on any of the stars.  This functionality does not work for all other records created in my ListView.  I am using .Net Framework 4.0 with ClientIdMode set to static.  Therefore, every Rating Control created is being assigned the same ID.  I did this because in CodeBehind I need to know which Star value was clicked on a particular record (i.e. in the Rating_Changed method).  In the code snippet window I am showing the markup that gets created.  This markup is repeated for every record in my datasource (every Rating Control generates the same markup).  Does anyone have any idea how to get this to work?  

Rating Control Markup:
<asp:Rating ID="Rating" runat="server"
  MaxRating="5"
  CurrentRating="2"
  CssClass="ratingStar"
  StarCssClass="ratingItem"
  WaitingStarCssClass="Saved"
  FilledStarCssClass="Filled"
  EmptyStarCssClass="Empty" AutoPostBack="True" OnChanged="Rating_Changed"
  >
</asp:Rating>
<div id="Rating" class="ratingStar">
<input type="hidden" name="ctl00$Tab1ContentPlaceHolder$lvMovies$ctrl0$ctl05$Rating_RatingExtender_ClientState" id="Rating_RatingExtender_ClientState" value="2" />
<a href="javascript:void(0)" id="Rating_A" title="2" style="text-decoration:none">
<span id="Rating_Star_1" class="ratingItem Filled" style="float:left;">&nbsp;</span>
<span id="Rating_Star_2" class="ratingItem Filled" style="float:left;">&nbsp;</span>
<span id="Rating_Star_3" class="ratingItem Empty" style="float:left;">&nbsp;</span>
<span id="Rating_Star_4" class="ratingItem Empty" style="float:left;">&nbsp;</span>
<span id="Rating_Star_5" class="ratingItem Empty" style="float:left;">&nbsp;</span></a>
</div>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of buraksarica
buraksarica
Flag of Türkiye image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of obautista
obautista

ASKER

Thank you.