Ratingextender is used to evaluate a thing. It allows you to customize the level.
The following is an example:
1) Create an ASP. NET Ajax-enabled web project in vs2005 and name it ratingextender1.
2) drag and drop an updatepanel on the default. aspx page and name it updatepanel1. Drag and Drop a ratingextender in updatepanel1 and name it rating1 for movie review. Drag and Drop two dropdownlists under rating1. One is used to set the alignment direction and the other is used to arrange the direction.
3) drag and drop a button and label to display your score.
CodeAs follows: 1 < ASP: updatepanel ID = "Updatepanel1" Runat = "Server" >
2 < Contenttemplate >
3 Evaluate the film: < C0: Rating ID = "Rating1" Runat = "Server" Currentrating = "2" Starcssclass = "Ratingstar" Filledstarcssclass = "Filledratingstar" Emptystarcssclass = "Emptyratingstar" Waitingstarcssclass = "Savedratingstar" Onchanged = "Ratingtransferchanged" >
4 </ C0: Rating >
5 < BR />
6 Conversion alignment mode: < ASP: dropdownlist ID = "Dropdownlist1" Runat = "Server" Autopostback = "True" >
7 < ASP: listitem > Horizontal </ ASP: listitem >
8 < ASP: listitem > Vertical </ ASP: listitem >
9 </ ASP: dropdownlist > < BR />
10 Change the direction of movement: < ASP: dropdownlist ID = "Dropdownlist2" Runat = "Server" Autopostback = "True" >
11 < ASP: listitem > Left to right or top to bottom </ ASP: listitem >
12 < ASP: listitem > Right to left or bottom to top </ ASP: listitem >
13 </ ASP: dropdownlist > < BR />
14 & Nbsp; < ASP: button ID = "Button1" Runat = "Server" Onclick = "Button#click" Text = "Button" /> < BR />
15 < ASP: Label ID = "Label1" Runat = "Server" > </ ASP: Label >
16 </ Contenttemplate >
17 </ ASP: updatepanel >
Attribute description:
Currentrating: The default rating level.
Starcssclass: This control displays the CSS style used.
Filledstarcssclass: The CSS style applied after the control is filled.
Emptystarcssclass: When no part is clicked in the control, the mouse does not slide over the CSS style applied to the part.
Waitingstarcssclass: The unclicked part of the control. The CSS style is used when the mouse slides.
Onchanged: The content to be executed when the control level is changed.
4) then add the content of the ratingdomainchanged event.
The Code is as follows:
System. Threading. thread. Sleep (1000 );
The main function of this Code is to delay and let you feel its changes.
5) then add code in the page_load event to respond to the return of the two dropdownlist controls.
The Code is as follows:
1 Rating1.ratingalign = (Dropdownlist1.selectedindex = 1 ) ? Orientation. Vertical: orientation. horizontal;
2 Rating1.ratingdirection = (Dropdownlist2.selectedindex = 1 ) ? Ratingdirection. righttoleftbottomtotop: ratingdirection. lefttorighttoptobottom;
3
6) add an event function to the button control to display your score.
The Code is as follows: 1 Int Rate = 0 ;
2 Switch (Rating1.currentrating)
3 {
4 Case 1 :
5 Rate = 1 ;
6 Break ;
7 Case 2 :
8 Rate = 2 ;
9 Break ;
10 Case 3 :
11 Rate = 3 ;
12 Break ;
13 Case 4 :
14 Rate = 4 ;
15 Break ;
16 Case 5 :
17 Rate = 5 ;
18 Break ;
19 }
20
21 If (Rate = 0 )
22 {
23This. Label1.text= "You have not commented on this film";
24}
25 Else
26 {
27This. Label1.text= "Your score is" +Rate;
28}
7) press Ctrl + F5 to view the effect in the browser.
As follows: