Unrate the first star

4 posts, 0 answers
  1. ARVIN
    ARVIN avatar
    2 posts
    Member since:
    Sep 2011

    Posted 28 Sep 2011 Link to this post

    Hello all,

    I am able to unrate other stars by clicking on already rated star now what  I need is to unrate the first star by clicking on it again

    Thanks,
    aRviN
  2. Niko
    Admin
    Niko avatar
    387 posts

    Posted 03 Oct 2011 Link to this post

    Hi Arvin,

    You could track the changes in the rating by handling the OnClientRated event. In there you can check if the old value is 1 and the new value is 1 again, then you can force the value to 0. Here is a sample handler method to accomplish this:
    function unrateOnFirstStar(rating, args) {
        if(args.get_oldValue() == 1 && rating.get_value() == 1)
            rating.set_value(0);
    }

    Hope this helps.

    All the best,
    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. lupotana
    lupotana avatar
    73 posts
    Member since:
    Nov 2006

    Posted 18 Nov 2011 Link to this post

    Ok for the client... but If I want use in a server side code ?

    I have 3 state and I want use only two star.. 0 and 1  and 2.
    When I click on a star I must enter in a function server side.

    Is it possible ?
  5. Niko
    Admin
    Niko avatar
    387 posts

    Posted 21 Nov 2011 Link to this post

    Hello Lupotana,

      Even though the solution is on the client-side, it should work just fine with a RadRating control that is set to autopostback, because the client-side event handler will be called just before the page is being sent to the server.
    Still if you wish to completely escape the client-side code, then you will need to have a way to persist the old value of the RadRating control on the server side and in the OnRate event handler you need to make the same checks and assignments as in the client-side approach.

    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
Back to Top