Click here to Skip to main content
11,925,381 members (59,232 online)
Click here to Skip to main content
Add your own
alternative version


75 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 2:19
memberlakshmant.khms27-Apr-15 2:19 
AnswerRe: How to get the value in Javascript? Pin
taihip3-Sep-15 19:31
membertaihip3-Sep-15 19:31 
GeneralThank you Pin
BLD5198-Jan-14 6:37
memberBLD5198-Jan-14 6:37 
GeneralMy vote of 1 Pin
Member 1021431823-Oct-13 0:56
memberMember 1021431823-Oct-13 0:56 
GeneralMy vote of 3 Pin
somnathmandal5-Oct-13 2:21
membersomnathmandal5-Oct-13 2:21 
GeneralMy vote of 3 Pin
Tapan Parida18-Oct-12 3:12
memberTapan Parida18-Oct-12 3:12 
Question5 Stars! Pin
ldsgomes16-Jun-12 8:14
memberldsgomes16-Jun-12 8:14 
AnswerRe: 5 Stars! Pin
vijayviki729-Nov-12 0:05
membervijayviki729-Nov-12 0:05 
GeneralRe: 5 Stars! Pin
taihip29-Nov-12 0:59
membertaihip29-Nov-12 0:59 
GeneralRe: 5 Stars! Pin
vijayviki729-Nov-12 1:58
membervijayviki729-Nov-12 1:58 

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
Web02 | 2.8.151126.1 | Last Updated 18 Apr 2011
Article Copyright 2009 by taihip
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid