Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Rating > RadRating : OnRate Event is not firing

Not answered RadRating : OnRate Event is not firing

Feed from this thread
  • Thenmozhi avatar

    Posted on Feb 2, 2011 (permalink)

    Hi,
    I have a page which will have the rad rating control.

    Actually i am trying to get the selected value while user clicks on the rating item.

    This is my aspx page code

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="testpage.aspx.cs" Inherits="testpage" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
         
    </head>
    <body>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
       
        <form id="form1" runat="server">
        <telerik:RadRating ID="ratingBar" runat="server" Orientation="Horizontal" ItemHeight="61px"
                            ItemWidth="11px" CssClass="ratingClass" OnRate="RadRating1_Rate" Precision="Exact" AutoPostBack="True">
                            <Items>
                                <telerik:RadRatingItem Value="1" HoveredImageUrl="Images/Rating/Rating1/1h.png" HoveredSelectedImageUrl="Images/Rating/Rating1/1h.png"
                                    SelectedImageUrl="Images/Rating/Rating1/1s.png" ImageUrl="Images/Rating/Rating1/1.png" ToolTip="Very Low"  />
                                <telerik:RadRatingItem Value="2" HoveredImageUrl="Images/Rating/Rating1/2h.png" HoveredSelectedImageUrl="Images/Rating/Rating1/2h.png"
                                    SelectedImageUrl="Images/Rating/Rating1/2s.png" ImageUrl="Images/Rating/Rating1/2.png" ToolTip="Low" />
                                <telerik:RadRatingItem Value="3" HoveredImageUrl="Images/Rating/Rating1/3h.png" HoveredSelectedImageUrl="Images/Rating/Rating1/3h.png"
                                    SelectedImageUrl="Images/Rating/Rating1/3s.png" ImageUrl="Images/Rating/Rating1/3.png" ToolTip="Medium" />
                                <telerik:RadRatingItem Value="4" HoveredImageUrl="Images/Rating/Rating1/4h.png" HoveredSelectedImageUrl="Images/Rating/Rating1/4h.png"
                                    SelectedImageUrl="Images/Rating/Rating1/4s.png" ImageUrl="Images/Rating/Rating1/4.png" ToolTip="Medium-High" />
                                <telerik:RadRatingItem Value="5" HoveredImageUrl="Images/Rating/Rating1/5h.png" HoveredSelectedImageUrl="Images/Rating/Rating1/5h.png"
                                    SelectedImageUrl="Images/Rating/Rating1/5s.png" ImageUrl="Images/Rating/Rating1/5.png" ToolTip="High" />
                                <telerik:RadRatingItem Value="6" HoveredImageUrl="Images/Rating/Rating1/6h.png" HoveredSelectedImageUrl="Images/Rating/Rating1/6h.png"
                                    SelectedImageUrl="Images/Rating/Rating1/6s.png" ImageUrl="Images/Rating/Rating1/6.png" ToolTip="Very High" />
                            </Items>
            
                        </telerik:RadRating>

        <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /><br /><asp:Label ID="Label1" runat="server"
            Text="Label"></asp:Label>

      

        </form>
    </body>
    </html>

    Here is my Code behind

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Collections.ObjectModel;
    using System.IO;
    using System.Drawing;
    using Telerik.Web.UI;
    public partial class testpage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }
      
        protected void Button1_Click(object sender, EventArgs e)
        {
            Label1.Text = ratingBar.Value.ToString();
        }

        protected void RadRating1_Rate(object sender, EventArgs e)
        {
            Label1.Text = ratingBar.Value.ToString();
        }
    }

    I can able to get the selected value on button click.

    But the Onrate is not working.Even in debug mode I checked.

    The OnRate event is not fired while clicking on the Rating control.

    Please can any one suggest me how to proceed with this.

    Thanks in Advance
    Thenmozhi.R

    Reply

  • Niko Niko admin's avatar

    Posted on Feb 3, 2011 (permalink)

    Hello Thenmozhi,

    In the code sample that you provided I noticed a couple of inconsistencies.
    1. The RadScriptManager must be inside the form, otherwise there will be a runtime error -  "System.Web.HttpException: Control 'RadScriptManager1' of type 'RadScriptManager' must be placed inside a form tag with runat=server."
    2. Set the ItemCount property value to 6 (the number of items in the Items collection).
    Apart from this, the example works just fine. Please, find attached the modified aspx file and try rerunning the example with it.

    If you continue to experience problems with the event's behavior, please, provide a sample working project to be able to reproduce it.

    Kind regards,
    Nikodim
    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.
    Attached files

    Reply

  • Thenmozhi avatar

    Posted on Feb 9, 2011 (permalink)

    Hi,

    I have the this issue still.

    What i need is on click of the Rating control i need to update the rated value to Database.

    Planing to place it in Grid. For each query rated values will be saved to database.

    In the given code.In button click i can able to get the rated values and can able to update.

    But on rate it is not happening.

    Please guide me how to achieve this.

    Sorry i have created a sample project but i couldn't able to attach my zip here.

    Thanks
    Thenmozhi.R

    Reply

  • Niko Niko admin's avatar

    Posted on Feb 10, 2011 (permalink)

    Hello Thenmozhi,

    Could you check the version of the RadControls that you are using and let me know if they are not the latest? It is because I have tested this scenario with the latest version and no problems occurred.

    Please, find attached a sample project with an example implementation of the RadRating OnRate event. Try running the Default.aspx page.
    • Clicking on the RadRating control (choosing a new value) should fire the OnRate event, populating the Text property of the Label.
    • Clicking on the Button should result in firing its click event. The content of the Label should be different, but the value of the RadRating should still be present.
    Please, let me know of the outcome.

    If you need an example solution for using RadRating inside a RadGrid, you could refer to the Telerik demos Application Scenario - "RadRating in RadGrid".

    Best wishes,
    Nikodim
    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.
    Attached files

    Reply

  • Thenmozhi avatar

    Posted on Feb 10, 2011 (permalink)

    Hi,
    Thanks for your support.

    If i open your project and RUN it is working fine.

    But if i place the code to my application it is not.

    Even i placed your DLL's to my bin.

    As i am in critical time line please help me out.

    What needs to be checked in my End.

    Thanks
    Thenmozhi.R

    Reply

  • Niko Niko admin's avatar

    Posted on Feb 10, 2011 (permalink)

    Hi Thenmozhi,

    Please, make sure that there are no javascript errors (this may prevent the postback to the server, i.e. the OnRate event). If there are any errors, being client or server side, you can send the logs from them. Still the best options will be to send me a sample project that reproduces the problem in order to investigate it in depth.

    Regards,
    Nikodim
    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.

    Reply

  • Thenmozhi avatar

    Posted on Feb 11, 2011 (permalink)

    Hi,

    Thanks for your effort.

    I solved the issue.

    I looked into webconfig and i removed the below one.

    It started working.

    <xhtmlConformance mode="Legacy"/>

    Thanks
    Thenmozhi.R

    Reply

  • Zura Chikhladze avatar

    Posted on Mar 22, 2011 (permalink)

    Hi,

    I am facing this small issue. the thing is that i want to display the average rating from the database (sqldatabase). i just cannot figure it out how can i bind the radrating to sql in order to insert and display the average value. i read your databinding section of the radrating, won't be able to  figure ItemBinding.ValueField property.  What i want it to do is that OnRate i want to insert the value in the database and then show the average voting.

    This is my aspx page code


    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
       
        <telerik:RadRating ID="ratingBar" runat="server" AutoPostBack="True"
            ItemCount="6" OnRate="RadRating1_Rate" Orientation="Horizontal"
            Precision="Item" Skin="Outlook" Width="100px">
        </telerik:RadRating>
        <br />
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br />
        <br />
        <asp:Label ID="lblAverageRating" runat="server" Text="Label"></asp:Label>
         
        </form>


    Here is my Code behind

    protected void RadRating1_Rate(object sender, EventArgs e)
            {
                Label1.Text = "Your Current rating is: " + ratingBar.Value.ToString();
            }

    With Label1 i can display the current rating and below that label i have lblAverageRating where i want to display the average vote.
    Sql database is very simple, the database file is RadRating.mdf and has one table called Vote. The table has 2 columns: ID and Rate.
    From the Rate column i have to extract the average rating.

    thank you so much in advance. z.



    Reply

  • Niko Niko admin's avatar

    Posted on Mar 22, 2011 (permalink)

    Hi Thenmozhi,

    Please, refer to the demos for RadRating, namely the one with the RadGrid - http://demos.telerik.com/aspnet-ajax/rating/examples/gridrating/defaultcs.aspx. This demo show how to implement average ratings using the RadRating within RadGrid, utilizing the OnRate event of the RadRating control. Hope this will be of help.

    All the best,
    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.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Rating > RadRating : OnRate Event is not firing
Related resources for "RadRating : OnRate Event is not firing"

ASP.NET Rating Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  |  Step-by-step Tutorial  ]