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

OnClientRating & Ratting Zero

1 Answer 85 Views
Rating
This is a migrated thread and some comments may be shown as answers.
Mohammad Hajinezhad
Top achievements
Rank 1
Mohammad Hajinezhad asked on 03 Jun 2010, 07:34 PM
Hi everyone

I have two issue with RadRatting, I hope someone could help me.

1- I don't know have could get value of RadRatting for validation on "OnClientRating" event, sender.get_value() just give me Old-Value, Not Current-value !!!!!!

2- I don't know have rat 0, when ratted some value, for Example when I Rate 5 star, I can't change value to 0 star (I prefer do this, whit user click, Not with programming).

3- It is possible that force end-users to just ratting between two values (for examples ratting between 3-8) ?!!!!!!!!

Best Regards,
M.Hajinezhad.

1 Answer, 1 is accepted

Sort by
0
Tsvetie
Telerik team
answered on 09 Jun 2010, 10:19 AM
Hi Mohammad Hajinezhad,
Straight to your questions:
  1. The rating client-side event of the rating control is raised before the value of the control changes. That is why, get_value returns the old value - it is actually the current value of the control. You can obtain the pending value the following way:
    <telerik:RadRating ID="RadRating1" runat="server" OnClientRating="OnClientRating">
    </telerik:RadRating>
    <script type="text/javascript">
    function OnClientRating(sender, args)
    {
        alert(args.get_newValue());
    }
    </script>
  2. I am not quite sure how you want to implement this. In case you want a separate button that resets the value of the rating control to 0, you can simply define a button, style it per your specification and use its click client-side event to set the value of the rating control to 0:
    <telerik:RadRating ID="RadRating1" runat="server">
    </telerik:RadRating>
    <asp:Button ID="Button1" runat="server" OnClientClick="OnClientClick(); return false;" />
    <script type="text/javascript">
    function OnClientClick()
    {
        $find("<%= RadRating1.ClientID %>").set_value(0);
    }
    </script>
    . On the other hand, in case you want the first item in the rating to have value=0, you can use the Items collection of the control - http://demos.telerik.com/aspnet-ajax/rating/examples/itemscollection/defaultcs.aspx.
  3. Yes, you can - you can use the Items collection of the rating control and set the Value for each item - http://demos.telerik.com/aspnet-ajax/rating/examples/itemscollection/defaultcs.aspx.

Regards,
Tsvetie
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Rating
Asked by
Mohammad Hajinezhad
Top achievements
Rank 1
Answers by
Tsvetie
Telerik team
Share this question
or