Click here to Skip to main content
12,560,367 members (47,161 online)
Click here to Skip to main content
Add your own
alternative version


76 bookmarked

ASP.NET Rating Control

, 18 Apr 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
An ASP.NET rating control


There are many free rating controls on the internet, but I didn't find any control which fits these features:

  • Works well in UpdatePanel, GridView
  • Easy to customize UI and behavior
  • Auto generates JavaScript (does not need an external JS file)

So I decided to write an ASP.NET custom control as per my requirements.

Using the Code

How to use this control?

  1. Add a reference to the control,
  2. and:
    <%@ Page Language="C#" AutoEventWireup="true" 
    	Codebehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
    <%@ Register Namespace="ASPnetRater" Assembly="ASPnetRater" TagPrefix="cc" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    <html xmlns="">
    <head runat="server">
        <title>Untitled Page</title>
        <form id="form1" runat="server">
                <cc:Rater ID="Rater1" runat="server" 
                    Value="3" MaxValue="5" ImageOn="/assets/images/rating_red_star.gif"
                    ToolTip="I'm a rater" OnCommand="Rater1_Command" 

This is the result:

Normal Status

Hover Status

Points of Interest

If you want the control to work well in an UpdatePanel, please make the control become a trigger of UpdatePanel:



  • April 08, 2009: First draft
  • April 15, 2010: Updates
    • Fixed a bug while posting back, as reported by yuyejian
    • Uses the Enabled property to enable/disable the control
    • Image's URL supports URLs like "~/assets/..."
  • June 29, 2010: Updated source code
    • Fixed bug reported by maorray (Doesn't save/load the value of the rater to ControlState)
  • April 18, 2011: Updated source code
    • Added CommandName property
    • Calls base.RaiseBubbleEvent() in OnCommand()
    • This update will help the parent control such as GridView, DataList and the like to catch OnItemCommand event.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer SEA-Solutions
Vietnam Vietnam
No Biography provided

You may also be interested in...


Comments and Discussions

QuestionHow to get the value in Javascript? Pin
lakshmant.khms27-Apr-15 1:19
memberlakshmant.khms27-Apr-15 1:19 
AnswerRe: How to get the value in Javascript? Pin
taihip3-Sep-15 18:31
membertaihip3-Sep-15 18:31 
GeneralThank you Pin
BLD5198-Jan-14 5:37
memberBLD5198-Jan-14 5:37 
GeneralMy vote of 1 Pin
Member 1021431822-Oct-13 23:56
memberMember 1021431822-Oct-13 23:56 
GeneralMy vote of 3 Pin
somnathmandal5-Oct-13 1:21
membersomnathmandal5-Oct-13 1:21 
GeneralMy vote of 3 Pin
Tapan Parida18-Oct-12 2:12
memberTapan Parida18-Oct-12 2:12 
Question5 Stars! Pin
ldsgomes16-Jun-12 7:14
memberldsgomes16-Jun-12 7:14 
AnswerRe: 5 Stars! Pin
vijayviki728-Nov-12 23:05
membervijayviki728-Nov-12 23:05 
GeneralRe: 5 Stars! Pin
taihip28-Nov-12 23:59
membertaihip28-Nov-12 23:59 
GeneralRe: 5 Stars! Pin
vijayviki729-Nov-12 0:58
membervijayviki729-Nov-12 0:58 
GeneralRe: 5 Stars! Pin
taihip9-Dec-12 16:29
membertaihip9-Dec-12 16:29 
GeneralRe: 5 Stars! Pin
vijayviki712-Dec-12 20:18
membervijayviki712-Dec-12 20:18 
QuestionExample needed on Rater Control Pin
premalvala25-Jul-11 3:48
memberpremalvala25-Jul-11 3:48 
AnswerRe: Example needed on Rater Control Pin
taihip25-Jul-11 4:15
membertaihip25-Jul-11 4:15 
QuestionDataList [modified] Pin
zoran Jancic zozo18-Apr-11 1:46
memberzoran Jancic zozo18-Apr-11 1:46 
AnswerRe: DataList Pin
taihip18-Apr-11 15:34
membertaihip18-Apr-11 15:34 
GeneralRe: DataList Pin
zoran Jancic zozo18-Apr-11 20:25
memberzoran Jancic zozo18-Apr-11 20:25 
GeneralMouse Over Pin
Member 42101356-Dec-10 21:41
memberMember 42101356-Dec-10 21:41 
GeneralRe: Mouse Over Pin
taihip6-Dec-10 21:56
membertaihip6-Dec-10 21:56 
QuestionRe: Mouse Over Pin
Member 42101356-Dec-10 22:15
memberMember 42101356-Dec-10 22:15 
AnswerRe: Mouse Over Pin
taihip6-Dec-10 22:31
membertaihip6-Dec-10 22:31 
GeneralRe: Mouse Over Pin
Member 42101357-Dec-10 22:13
memberMember 42101357-Dec-10 22:13 
Questionhow i get vote value in cs Pin
yuyejian13-Apr-10 21:41
memberyuyejian13-Apr-10 21:41 
AnswerRe: how i get vote value in cs Pin
taihip14-Apr-10 5:36
membertaihip14-Apr-10 5:36 
GeneralRe: how i get vote value in cs Pin
yuyejian14-Apr-10 18:56
memberyuyejian14-Apr-10 18:56 
GeneralRe: how i get vote value in cs Pin
taihip15-Apr-10 2:58
membertaihip15-Apr-10 2:58 
GeneralProblem with UpdatePanel Pin
Member 39168742-Feb-10 2:03
memberMember 39168742-Feb-10 2:03 
GeneralRe: Problem with UpdatePanel Pin
taihip2-Feb-10 5:11
membertaihip2-Feb-10 5:11 
GeneralRe: Problem with UpdatePanel Pin
Member 39168742-Feb-10 5:13
memberMember 39168742-Feb-10 5:13 
GeneralRe: Problem with UpdatePanel Pin
taihip3-Feb-10 3:47
membertaihip3-Feb-10 3:47 
GeneralRe: Problem with UpdatePanel Pin
maorray29-Jun-10 1:31
membermaorray29-Jun-10 1:31 
GeneralRe: Problem with UpdatePanel Pin
taihip29-Jun-10 4:14
membertaihip29-Jun-10 4:14 
GeneralRe: Problem with UpdatePanel Pin
maorray29-Jun-10 4:30
membermaorray29-Jun-10 4:30 
GeneralRe: Problem with UpdatePanel Pin
taihip29-Jun-10 5:08
membertaihip29-Jun-10 5:08 
GeneralResolveUrl Pin
ernest_elias18-Jun-09 2:21
memberernest_elias18-Jun-09 2:21 
AnswerRe: ResolveUrl [modified] Pin
taihip18-Jun-09 15:37
membertaihip18-Jun-09 15:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.161026.1 | Last Updated 18 Apr 2011
Article Copyright 2009 by taihip
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid