Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / ASP.NET

Rating Control using Custom Web Control

3.60/5 (4 votes)
6 Feb 2009CPOL 1   702  
Custom web control using ASP.NET

Introduction

Well, I was working on a project in which I required a rating control. This rating control is developed using web control class in which we have 4 properties. By using these properties, we can use the rating control.

Background

I Googled and found paid rating controls. Then I decided to develop my own rating control.

Using the Code

Using this control is very easy. We have a class Voting in MyVote namespace. In the Voting class, we have 4 properties.

In this control, we have 4 properties in MyVotele or code.

View online demo.

  • VoteCount: It will return the number of vote users have clicked.
  • MouseOver_ImagePath: Set the image path of Mouse over image.
  • MouseOut_ImagePath: Set the image path of Mouse out image.
  • StarCount: Set the number of stars to be displayed in rating control.

In a *.aspx page, you have to register a control:

ASP.NET
<%@ Register TagPrefix="MyBar" Namespace="MyVote" %> 

In a *.aspx page between form tags, write this:

ASP.NET
<MyBar:voting runat="server" id="RatingCtrl" width="100px" StarCount="5"
 MouseOut_ImagePath="star.jpg" MouseOver_ImagePath="starover.jpg" 
	OnClick="RatingCtrl_Click" >
</MyBar:voting> 

Points of Interest

This control is very easy to use in different pages.

License

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