Acces to a Nested RadRating Property in JavaScript Function(Handling OnClientRated)

7 posts, 2 answers
  1. Ahmad
    Ahmad avatar
    13 posts
    Member since:
    Jul 2010

    Posted 18 Apr 2011 Link to this post

    Hi,
    After writing OnClientRated Function for a RadRating (A nested one) as below:

    function OnClientRated(sender, args)
    {
        ...
    }

    How Can I Convert sender to RadRating here, My goal is to access a property of my specific RadRating Control(I'm using RadRating in a DataList Control ). I know that I can do it in ItemDataBound event of DataList, But it's not good enough considering that I have to use the value here in JavaScript Function(I'm going to use it as a QueryString Value in order to redirect to a page shown in RadWindow).
    Would you please help me out?
  2. Answer
    Niko
    Admin
    Niko avatar
    387 posts

    Posted 20 Apr 2011 Link to this post

    Hi Ahmad,

    The sender argument is indeed the rating object. In JavaScript, being a scripting language, there is no casting. Therefore you can directly use the sender as an instance of RadRating.
    function OnClientRated(sender, args)
    {
        var value = sender.get_value();
    }
    Or even better, the way I am used to writing the event handlers on the client side:
    function OnClientRated(rating, args)
    {
        var value = rating.get_value();
    }


    Hope this helps.

    Regards,
    Niko
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ahmad
    Ahmad avatar
    13 posts
    Member since:
    Jul 2010

    Posted 20 Apr 2011 Link to this post

    Hi Niko
    Thanks for your answer, I tried it and it works, the question is, I wish to access ToolTip Property of my rating, it's not working whatever I do, Would you please help me out in this matter?
  5. Answer
    Niko
    Admin
    Niko avatar
    387 posts

    Posted 20 Apr 2011 Link to this post

    Hello Ahmad,

    On the client-side the ToolTip attribute is rendered as a title attribute. Therefore you need to look for the title instead. Here is a sample code to accomplish this:
    function showToolTip(rating, args)
    {
        alert($get(rating.get_id()).getAttribute("title"));
    }

    Please, let me know if you will need anything else.

    Best wishes,
    Niko
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  6. Ahmad
    Ahmad avatar
    13 posts
    Member since:
    Jul 2010

    Posted 20 Apr 2011 Link to this post

    Thank you so much!
  7. Ahmad
    Ahmad avatar
    13 posts
    Member since:
    Jul 2010

    Posted 27 Apr 2011 Link to this post

    Hello again,

    In the same scenario I need to fire both Rated and OnClientRated events, but it seems that when I use OnClientRated, the Rated event is not even fired, would you please help me out in this matter? Is there any way to have both events working, or an alternative event?

    Thanks
  8. Niko
    Admin
    Niko avatar
    387 posts

    Posted 27 Apr 2011 Link to this post

    Hi Ahmad,

    The problem may be caused by a browser dialog, i.e. alert, confirm, prompt. etc. Please, make sure that you are not raising any of these, as this will prevent the postback to the server. Also make sure that there are no JavaScript errors in the handler function. Otherwise, I will need to check the code of the event handler for anything that may be causing the incorrect behavior.

    Best wishes,
    Niko
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017