0

I've downloaded the ajaxtoolkit earlier today, and I've tried to do something very basic with the Rating object, however, the OnChanged event isn't firing at all - Can someone explain to me what I did wrong?

The Code:

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

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .Star {
            background-image: url(images/Star.png);
            height: 30px;
            width: 30px;
            background-repeat: no-repeat;
        }

        .FilledStar {
            background-image: url(images/FilledStar.png);
            height: 30px;
            width: 30px;
            background-repeat: no-repeat;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <asp:Label ID="Label1" runat="server" Text="Your Current Rating is...."></asp:Label>
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div>
            <ajaxToolkit:Rating ID="Rating1" OnChanged="Rating1_Changed"  AutoPostBack="true" runat="server"
                StarCssClass="Star" EmptyStarCssClass="Star"
                FilledStarCssClass="FilledStar" WaitingStarCssClass="Star">
            </ajaxToolkit:Rating>
        </div>
    </form>
</body>
</html>

The code behind:

   using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Rating1_Changed(object sender, AjaxControlToolkit.RatingEventArgs e)
    {
        Label1.Text = Rating1.CurrentRating.ToString();
    }
}

This is my first post here so I'm sorry if I did something wrong :$ Thank You!

HanzoS
  • 21
  • 1
  • 3
  • `Rating` should go inside an `UpdatePanel`. – jsanalytics May 26 '18 at 11:51
  • Take a look at https://stackoverflow.com/questions/53993572/retrieve-ajax-star-rating-value-to-asp-net-backend/53994025?noredirect=1#comment94825612_53994025 – Aria Jan 01 '19 at 08:39

1 Answers1

0

fire click event instead of change event.. it will definitely work