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

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

6 Answers 59 Views
Rating
This is a migrated thread and some comments may be shown as answers.
Ahmad
Top achievements
Rank 1
Ahmad asked on 18 Apr 2011, 03:26 PM
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?

6 Answers, 1 is accepted

Sort by
0
Accepted
Niko
Telerik team
answered on 20 Apr 2011, 08:49 AM
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.

0
Ahmad
Top achievements
Rank 1
answered on 20 Apr 2011, 08:55 AM
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?
0
Accepted
Niko
Telerik team
answered on 20 Apr 2011, 09:48 AM
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.

0
Ahmad
Top achievements
Rank 1
answered on 20 Apr 2011, 04:28 PM
Thank you so much!
0
Ahmad
Top achievements
Rank 1
answered on 27 Apr 2011, 09:17 AM
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
0
Niko
Telerik team
answered on 27 Apr 2011, 12:17 PM
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.

Tags
Rating
Asked by
Ahmad
Top achievements
Rank 1
Answers by
Niko
Telerik team
Ahmad
Top achievements
Rank 1
Share this question
or