These controls
are often a simple manifestation of a finite rating system and usually appear as a
number of stars or other small icons. The Rating control provides very similar functionality
by displaying a star-based Rating control with a minimum amount of code while
allowing the flexibility of applying various styles to get the intended appearance.
Table 8-12 lists the main properties of this control.
Table 8-12. Rating Extender Properties
Property Name Description
AutoPostBack Boolean value indicating whether or not postback is initiated with a
change in ratings
CurrentRating Current value of the Rating control
EmptyStarCssClass CSS class used for empty (unselected) stars
FilledStarCssClass CSS class used for filled (selected) stars
CHAPTER 8 ?– USING THE ASP.NET AJAX CONTROL TOOLKIT (PART 2) 190
MaxRating Highest possible rating
OnChanged Client-side event fired when the rating is changed
RatingAlign General alignment of the starts (Vertical/Horizontal)
RatingDirection Flow direction of the stars (LeftToRight, TopToBottom, etc.)
ReadOnly Boolean value indicating whether or not the rating can be changed
StarCssClass CSS class for stars in the Rating control
Tag Parameter used to store auxiliary information to pass to the client
WaitingStarCssClass CSS class for stars in waiting mode
Here we have an example of a Rating control with a max number of five stars (as
stated by the MaxRating property) with the initial rating set to two stars:
CurrentRating="2"
MaxRating="5"
StarCssClass="ratingStar"
WaitingStarCssClass="savedRatingStar"
FilledStarCssClass="filledRatingStar"
EmptyStarCssClass="emptyRatingStar"
OnChanged="ThaiRating_Changed"
style="float: left;" />
The ThaiRating_Changed method simulates logic processing by 400ms of pause and
notifies the user as shown in the following code:
protected void ThaiRating_Changed(object sender, RatingEventArgs e)
{
Thread.
Pages:
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276