You must Sign In to post a response.
  • Category: ASP.NET

    5 star Rating in asp.net

    hi friends,
    how to store and retrive the 5 stars rating in asp.net. i'm trying but not get actuall results.
    Thanks and Regards
  • #766410
    Hi,

    I'm little bit confused could you please elaborate your requirement so that we can help you better, what do you mean by 5 star rating etc.?

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #766412
    Hi

    try this code

    client side



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

    <cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </cc1:ToolkitScriptManager>
    <cc1:Rating ID="Rating1" AutoPostBack="true" OnChanged="OnRatingChanged" runat="server"
    StarCssClass="Star" WaitingStarCssClass="WaitingStar" EmptyStarCssClass="Star"
    FilledStarCssClass="FilledStar">
    </cc1:Rating>
    <br />
    <asp:Label ID="lblRatingStatus" runat="server" Text=""></asp:Label>



    Server Side Code


    using (SqlDataAdapter da = new SqlDataAdapter(cmd))
    {
    con.Open();
    DataTable dt = new DataTable();
    da.Fill(dt);
    Total += Convert.ToInt32(dt.Rows[i][0].ToString());
    int Average = Total / (dt.Rows.Count);
    Rating1.CurrentRating = Average;
    Label2.Text = "Average rating for this Product is" + " " + Convert.ToString(Average);
    con.Close();
    }

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #766416
    5 Star rating is one logic. We do not need to following any style for doing this. You can use your own logic.
    Create table/fields for staging the rate value. This is completely depend on your requirement. Create one user control and decorate with stars (link/button..etc). Base on the click you can make server side call. In the server side call you can store the rate value against you product/article etc... Try to use the user control so that you can use it across your project

    By Nathan
    Direction is important than speed

  • #766419
    AJAX toolkit has AJAX asp.net rating control,
    1. Drag an ASP.Net AJAX ToolScriptManager on the page.
    2. Register the AJAX Control Toolkit Library after adding reference to your project
    see below snippet

    <%@ Page Language="VB" AutoEventWireup="true"
    CodeFile="Default.aspx.vb" Inherits="_Default" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
    <ajaxToolkit:Rating runat="server" ID="Rating1"
    MaxRating="5"
    CurrentRating="2"
    CssClass="ratingStar"
    StarCssClass="ratingItem"
    WaitingStarCssClass="Saved"
    FilledStarCssClass="Filled"
    EmptyStarCssClass="Empty"
    >
    </ajaxToolkit:Rating>

    see below links for more details
    http://www.codeproject.com/Articles/17399/AJAX-ASP-NET-Rating-Control
    http://www.aspsnippets.com/Articles/ASPNet-AJAX-Rating-Control-Example.aspx

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #766453
    Hi,
    You can use jQuery, please find some of the demo source codes:
    http://www.aspsnippets.com/Articles/Using-jQuery-Star-Rating-in-ASPNet.aspx
    http://imar.spaanjaars.com/410/building-a-simple-rating-control-for-aspnet-20
    http://dotnetawesome.blogspot.com/2013/12/how-to-implement-5-star-rating-system-inside-gridview.html


Sign In to post your comments