Add (Implement) 5 Star Rating System using AJAX Rating Extender in ASP.Net

Last Reply 10 months ago By dharmendr

Posted 10 months ago

Below is my sample code the gif images are from your solution but I see 4 stars instead of 1 star.

ASP.Net AJAX Rating Extender Control Database Example – How to save and display Average Rating value from database

So I am seeing 10 stars in 2 lines and 1 star is equal to 2 stars of both lines.

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="WebApplication1.WebForm1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!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>
    <style type="text/css">
.emptypng {
    background-image: url(Star.gif);
    width: 32px;
    height: 32px;
}
.smileypng {
    background-image: url(FilledStar.gif);
    width: 32px;
    height: 32px;
}
.donesmileypng {
    background-image: url(FilledStar.gif);
    width: 32px;
    height: 32px;
}
</style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="asm" runat="server"></asp:ScriptManager>
    <asp:Table ID="TableContent" runat="server">
</asp:Table> 
    </div>
    </form>
</body>
</html>

 

Public Class WebForm1
    Inherits System.Web.UI.Page
 
    Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As EventArgs) Handles Me.PreInit
        GetMenuHtml()
    End Sub
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 
    End Sub
    Private Sub GetMenuHtml()
        Dim tr As TableRow = New TableRow()
        Dim td As TableCell = New TableCell()
        Dim rbuttons As AjaxControlToolkit.Rating = New AjaxControlToolkit.Rating
        rbuttons.ID = "test"
        rbuttons.MaxRating = 5
        rbuttons.AutoPostBack = True
        rbuttons.EmptyStarCssClass = "emptypng"
        rbuttons.FilledStarCssClass = "smileypng"
        rbuttons.StarCssClass = "smileypng"
        rbuttons.WaitingStarCssClass = "donesmileypng"
 
 
        td.Controls.Add(rbuttons)
        td.Controls.Add(New LiteralControl("<br/>"))
        td.Controls.Add(New LiteralControl("<br/>"))
        tr.Controls.Add(td)
        TableContent.Rows.Add(tr)
    End Sub
End Class

 

This question does not have replies that have been liked.