Skip to main content

ASPxClientRatingControl.SetValue(value) Method

Modifies the value of the ASPxRatingControl on the client side.

Declaration

SetValue(
    value: number
): void

Parameters

Name Type Description
value number

The value of the control.

Remarks

Use the SetValue method to change the control’s value. The ASPxClientRatingControl.GetValue method can be used to obtain the value on the client. The ASPxRatingControl.Value property is used to set the control’s value on the server side.

Use the ASPxRatingControl.FillPrecision property to specify how the items should be filled if the control’s value is fractional.

Example

This part of the Voting demo illustrates how to use the ASPxRatingControl‘s ASPxRatingControl.Value property.

Here, the ASPxRatingControl item click initiates a callback on the server within the ASPxClientRatingControl.ItemClick client event. The total rating is calculated as an arithmetic mean for the current user on the server, and stores the control’s value (ASPxRatingControl.Value) by using the ASPxClientRatingControl.SetValue method.

protected void Page_Load(object sender, EventArgs e) {
         ...
         if(!IsCallback) {
             ratingControl.Value = GetRating();
         ...
         }
     }

     protected void cbVoting_Callback(object source, CallbackEventArgs e) {
         ...
         CurrentUserRatingValue = (int)ratingControl.Value;
         e.Result = string.Format("{0} {0:0.##}", GetRating());
     }

     public int? CurrentUserRatingValue { 
         get { return (int?)Session["CurrentUserRatingValue"]; }
         set { Session["CurrentUserRatingValue"] = value; }
     }
     public decimal GetRating() {
        ...
        //rating calculations
        ...
     }
 }
See Also