There are many free rating controls on the internet, but I didn't find any control which fits these features:
- Works well in
- Easy to customize UI and behavior
So I decided to write an ASP.NET custom control as per my requirements.
Using the Code
How to use this control?
- Add a reference to the control,
<%@ 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"
<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:
Points of Interest
If you want the control to work well in an
UpdatePanel, please make the control become a trigger of
- 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
- April 18, 2011: Updated source code
- This update will help the parent control such as
DataList and the like to catch