New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial

RadRating class

Definition

Namespace:Telerik.Web.UI

Assembly:Telerik.Web.UI.dll

Syntax:

C#
[EmbeddedSkin("Rating")]
[EmbeddedSkin("Rating", "Default")]
[RequiredCss("Telerik.Web.UI.Skins.Common.fonticons.css", RenderMode.Lightweight, typeof(RadRating))]
[ValidationProperty("Value")]
[ClientScriptResource("Telerik.Web.UI.RadRating", "Telerik.Web.UI.Rating.RadRating.js")]
[TelerikToolboxCategory("Miscellaneous")]
[ToolboxBitmap(typeof(RadRating), "Toolbox.Icons.Rating.png")]
[RequiredScript(typeof(jQueryPlugins))]
public class RadRating : RadDataBoundControl, IComponent, IDisposable, IParserAccessor, IUrlResolutionService, IDataBindingsAccessor, IControlBuilderAccessor, IControlDesignerAccessor, IExpressionsAccessor, IAttributeAccessor, IScriptControl, IControlResolver, IPostBackDataHandler, ISkinnableControl, IControl, IFeatureGroup, IPostBackEventHandler

Inheritance: objectControlWebControlBaseDataBoundControlDataBoundControlRadDataBoundControlRadRating...

Implements: IAttributeAccessorIComponentIControlIControlBuilderAccessorIControlDesignerAccessorIControlResolverIDataBindingsAccessorIDisposableIExpressionsAccessorIFeatureGroupIParserAccessorIPostBackDataHandlerIPostBackEventHandlerIScriptControlISkinnableControlIUrlResolutionService...

Inherited Members DataBoundControl.OnCreatingModelDataSource(CreatingModelDataSourceEventArgs)DataBoundControl.CreateDataSourceSelectArguments()DataBoundControl.GetData()DataBoundControl.GetDataSource()DataBoundControl.MarkAsDataBound()DataBoundControl.OnDataPropertyChanged()DataBoundControl.OnDataSourceViewChanged(object, EventArgs)DataBoundControl.OnLoad(EventArgs)DataBoundControl.OnPagePreLoad(object, EventArgs)DataBoundControl.PerformSelect()DataBoundControl.ValidateDataSource(object)DataBoundControl.DataMemberDataBoundControl.IsUsingModelBindersDataBoundControl.ItemTypeDataBoundControl.SelectMethodDataBoundControl.DataSourceIDDataBoundControl.DataSourceObjectDataBoundControl.SelectArgumentsDataBoundControl.CreatingModelDataSourceDataBoundControl.CallingDataMethodsBaseDataBoundControl.ConfirmInitState()BaseDataBoundControl.DataBind()BaseDataBoundControl.EnsureDataBound()BaseDataBoundControl.OnDataBound(EventArgs)BaseDataBoundControl.OnInit(EventArgs)BaseDataBoundControl.OnPreRender(EventArgs)BaseDataBoundControl.DataSourceBaseDataBoundControl.InitializedBaseDataBoundControl.IsBoundUsingDataSourceIDBaseDataBoundControl.IsDataBindingAutomaticBaseDataBoundControl.SupportsDisabledAttributeBaseDataBoundControl.RequiresDataBindingBaseDataBoundControl.DataBoundWebControl.ApplyStyle(Style)WebControl.CopyBaseAttributes(WebControl)WebControl.CreateControlStyle()WebControl.MergeStyle(Style)WebControl.Render(HtmlTextWriter)WebControl.RenderBeginTag(HtmlTextWriter)WebControl.RenderEndTag(HtmlTextWriter)WebControl.AccessKeyWebControl.AttributesWebControl.BackColorWebControl.BorderColorWebControl.BorderWidthWebControl.BorderStyleWebControl.ControlStyleWebControl.ControlStyleCreatedWebControl.CssClassWebControl.DisabledCssClassWebControl.StyleWebControl.EnabledWebControl.EnableThemingWebControl.FontWebControl.ForeColorWebControl.HasAttributesWebControl.HeightWebControl.IsEnabledWebControl.SkinIDWebControl.TabIndexWebControl.TagNameWebControl.ToolTipWebControl.WidthControl.ResolveAdapter()Control.HasEvents()Control.GetRouteUrl(object)Control.GetRouteUrl(string, object)Control.GetRouteUrl(RouteValueDictionary)Control.GetRouteUrl(string, RouteValueDictionary)Control.GetUniqueIDRelativeTo(Control)Control.ApplyStyleSheetSkin(Page)Control.OnDataBinding(EventArgs)Control.DataBind(bool)Control.DataBindChildren()Control.AddParsedSubObject(object)Control.EnsureID()Control.ClearChildState()Control.ClearChildControlState()Control.ClearChildViewState()Control.ClearEffectiveClientIDMode()Control.ClearCachedClientID()Control.Focus()Control.LoadControlState(object)Control.MapPathSecure(string)Control.OpenFile(string)Control.BuildProfileTree(string, bool)Control.SaveControlState()Control.RenderChildren(HtmlTextWriter)Control.RenderControl(HtmlTextWriter)Control.RenderControl(HtmlTextWriter, ControlAdapter)Control.OnUnload(EventArgs)Control.Dispose()Control.RaiseBubbleEvent(object, EventArgs)Control.OnBubbleEvent(object, EventArgs)Control.AddedControl(Control, int)Control.CreateControlCollection()Control.CreateChildControls()Control.ResolveUrl(string)Control.ResolveClientUrl(string)Control.FindControl(string)Control.FindControl(string, int)Control.GetDesignModeState()Control.HasControls()Control.IsLiteralContent()Control.EnsureChildControls()Control.RemovedControl(Control)Control.SetDesignModeState(IDictionary)Control.SetRenderMethodDelegate(RenderMethod)Control.ClientIDModeControl.ClientIDControl.ClientIDSeparatorControl.ContextControl.AdapterControl.DesignModeControl.EventsControl.IDControl.IsChildControlStateClearedControl.EnableViewStateControl.ViewStateModeControl.IsViewStateEnabledControl.NamingContainerControl.IdSeparatorControl.LoadViewStateByIDControl.PageControl.RenderingCompatibilityControl.TemplateControlControl.ParentControl.TemplateSourceDirectoryControl.AppRelativeTemplateSourceDirectoryControl.SiteControl.VisibleControl.UniqueIDControl.HasChildViewStateControl.ControlsControl.ValidateRequestModeControl.ViewStateControl.ViewStateIgnoresCaseControl.ChildControlsCreatedControl.IsTrackingViewStateControl.DisposedControl.DataBindingControl.InitControl.LoadControl.PreRenderControl.Unloadobject.ToString()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()object.GetType()object.MemberwiseClone()...

Constructors

C#
public RadRating()

Properties

Gets/Sets a value indicating whether the DataBound items should be appended to the Rating Items collection, or the collection should be cleared before creating the DataBound items.

C#
public bool AppendDataBoundItems { get; set; }

Get/Set a value indicating whether the RadRating control will initiate a postback after its value changes.

C#
[ClientControlProperty]
[ClientPropertyName("_autoPostBack")]
public bool AutoPostBack { get; set; }

The CssClass property will now be used instead of the former Skin and will be modified in AddAttributesToRender()

C#
protected override string CssClassFormatString { get; }

Overrides: RadDataBoundControl.CssClassFormatString

Example:
C#
protected override string CssClassFormatString
{
       get
       {
           return "RadDock RadDock_{0} rdWTitle rdWFooter";
       }
}

Gets or sets the value of RadRating in a database-friendly way.

C#
[Browsable(false)]
[TypeConverter(typeof(DecimalConverter))]
[Bindable(true, BindingDirection.TwoWay)]
public object DbValue { get; set; }
Property Value:

A decimal object that represents the value. The default value is 0m.

This property behaves exactly as the Value property. The only difference is that it will not throw an exception if the new value is null or DBNull. Setting a null value will revert the selected value to 0m.

Example:
cs-api-definition
private void Page_Load(object sender, System.EventArgs e)
{
RadRating1.DbValue = tableRow["Rating"];
}

Get/Set a value indicating whether the RadRating control will display a browser toolip for its values.

C#
[ClientControlProperty]
public bool EnableToolTips { get; set; }

Get/Set the direction of the RadRating control, that is, the position of the item (star) with value 1.

C#
[ClientControlProperty]
public bool IsDirectionReversed { get; set; }

Gets the object through which the user should provide the binding information about the rating items.

C#
[PersistenceMode(PersistenceMode.InnerProperty)]
public RatingItemBinding ItemBinding { get; }

Get/Set the number of items in the RadRating control - e.g. the number of stars that the control will have.

C#
[ClientControlProperty]
[ClientPropertyName("_itemCount")]
public int ItemCount { get; set; }

Get/Set the height of each item in the RadRating control.

C#
[ClientControlProperty]
[ClientPropertyName("_itemHeight")]
public Unit ItemHeight { get; set; }
Property Value:

Default: Unit.Empty

Gets a RadRatingItemCollection object that contains the items of the current RadRating control.

C#
[PersistenceMode(PersistenceMode.InnerProperty)]
public RadRatingItemCollection Items { get; }
Property Value:

A RadRatingItemCollection that contains the items of the current RadRating control. By default the collection is empty (RadRating creates its items, based on the value of its ItemCount property).

Use the Items property to access the child items of RadRating. You can add, remove or modify items from the Items collection.

Get/Set the width of each item in the RadRating control.

C#
[ClientControlProperty]
[ClientPropertyName("_itemWidth")]
public Unit ItemWidth { get; set; }
Property Value:

Default: Unit.Empty

Gets or sets a value indicating the client-side event handler that is called when the RadRating control is initialized.

C#
[ClientControlEvent]
[ClientPropertyName("load")]
public string OnClientLoad { get; set; }
Property Value:

A string specifying the name of the JavaScript function that will handle the event. The default value is an empty string.

Two parameters are passed to the handler:

  • sender, the RadRating object that raised the event.
  • args.

This event cannot be cancelled.

Example:
C#
The following example demonstrates how to use the <strong>OnClientLoad</strong> property.

<p>
    <div class="LanguageSpecific" name="Code_VB">
        &lt;script type="text/javascript"&gt;<br />
         function OnClientLoad(sender, args)<br />
         {<br />
             var ratingControl = sender;<br />
         }<br />
        &lt;/script&gt;
    </div>
    <div class="LanguageSpecific" name="Code_VB">
        &lt;telerik:RadRating ID="RadRating1" runat="server"<br />
        <strong>OnClientLoad="OnClientLoad"</strong>&gt;<br />
        ....<br />
        &lt;/telerik:RadRating&gt;
    </div>
</p>

Gets or sets a value indicating the client-side event handler that is called when the user clicks an item (star) of the RadRating control.

C#
[ClientControlEvent]
[ClientPropertyName("rated")]
public string OnClientRated { get; set; }
Property Value:

A string specifying the name of the JavaScript function that will handle the event. The default value is an empty string.

Two parameters are passed to the handler:

  • sender, the RadRating object that raised the event.
  • args.

This event cannot be cancelled.

Example:
C#
The following example demonstrates how to use the <strong>OnClientRated</strong> property.

<p>
    <div class="LanguageSpecific" name="Code_VB">
        &lt;script type="text/javascript"&gt;<br />
         function OnClientRated(sender, args)<br />
         {<br />
             var ratingControl = sender;<br />
         }<br />
        &lt;/script&gt;
    </div>
    <div class="LanguageSpecific" name="Code_VB">
        &lt;telerik:RadRating ID="RadRating1" runat="server"<br />
        <strong>OnClientRated="OnClientRated"</strong>&gt;<br />
        ....<br />
        &lt;/telerik:RadRating&gt;
    </div>
</p>

Gets or sets a value indicating the client-side event handler that is called when the user clicks an item (star) of the RadRating control, but before the new value is set.

C#
[ClientControlEvent]
[ClientPropertyName("rating")]
public string OnClientRating { get; set; }
Property Value:

A string specifying the name of the JavaScript function that will handle the event. The default value is an empty string.

Two parameters are passed to the handler:

  • sender, the RadRating object that raised the event.
  • args.

This event can be cancelled.

Example:
C#
The following example demonstrates how to use the <strong>OnClientRating</strong> property.

<p>
    <div class="LanguageSpecific" name="Code_VB">
        &lt;script type="text/javascript"&gt;<br />
         function OnClientRating(sender, args)<br />
         {<br />
             var ratingControl = sender;<br />
             args.set_cancel(true);
         }<br />
        &lt;/script&gt;
    </div>
    <div class="LanguageSpecific" name="Code_VB">
        &lt;telerik:RadRating ID="RadRating1" runat="server"<br />
        <strong>OnClientRating="OnClientRating"</strong>&gt;<br />
        ....<br />
        &lt;/telerik:RadRating&gt;
    </div>
</p>

Get/Set the orientation of the RadRating control.

C#
[ClientControlProperty]
public Orientation Orientation { get; set; }

Get/Set the rating precision for the RadRating control - the precision with which the user can rate.

C#
[ClientControlProperty]
public RatingPrecision Precision { get; set; }

Get/Set a value indicating whether the RadRating control is in read-only mode.

C#
[ClientControlProperty]
[ClientPropertyName("readOnly")]
public bool ReadOnly { get; set; }

Gets a RadRatingItem object that represents the selected item in the RadRating control in case Items collection of the control is not empty.

C#
[Browsable(false)]
public RadRatingItem SelectedItem { get; }
Property Value:

A RadRatingItem object that represents the selected item. If there are no items in the Items collection of the RadRating control, returns null.

Gets a RadRatingItemCollection object that contains the selected items in the RadRating control. The collection is empty in case there are no items in the Items collection of the control.

C#
[Browsable(false)]
public RadRatingItemCollection SelectedItems { get; }
Property Value:

A RadRatingItemCollection containing the selected items.

Get/Set the selection mode for the RadRating control - when the user rates, either mark a single item (star) as selected or all items(stars) from the first to the selected one.

C#
[ClientControlProperty]
public RatingSelectionMode SelectionMode { get; set; }
C#
protected override HtmlTextWriterTag TagKey { get; }

Overrides: WebControl.TagKey

Get/Set the current rating for the RadRating control.

C#
public decimal Value { get; set; }

Methods

Adds HTML attributes and styles that need to be rendered to the specified HtmlTextWriterTag. This method is used primarily by control developers.

C#
protected override void AddAttributesToRender(HtmlTextWriter writer)
Parameters:writerHtmlTextWriter

A HtmlTextWriter that represents the output stream to render HTML content on the client.

Overrides: RadDataBoundControl.AddAttributesToRender(HtmlTextWriter)

Binds the Rating control to a IEnumerable data source

C#
public void BindToEnumerableData(IEnumerable dataSource)
Parameters:dataSourceIEnumerable

IEnumerable data source

Code moved into this method from OnPreRender to make sure it executed when the framework skips OnPreRender() for some reason

C#
protected override void ControlPreRender()

Overrides: RadDataBoundControl.ControlPreRender()

C#
protected override void DescribeClientEvents(IScriptDescriptor descriptor)
Parameters:descriptorIScriptDescriptor

Overrides: RadDataBoundControl.DescribeClientEvents(IScriptDescriptor)

C#
protected override void DescribeClientProperties(IScriptDescriptor descriptor)
Parameters:descriptorIScriptDescriptor

Overrides: RadDataBoundControl.DescribeClientProperties(IScriptDescriptor)

C#
protected override void DescribeComponent(IScriptDescriptor descriptor)
Parameters:descriptorIScriptDescriptor

Overrides: RadDataBoundControl.DescribeComponent(IScriptDescriptor)

C#
public RadRatingItem FindItemByValue(decimal value)
Parameters:valuedecimalReturns:

RadRatingItem

Loads the client state data

C#
protected override void LoadClientState(Dictionary<string, object> clientState)
Parameters:clientStateDictionary<string, object>

Overrides: RadDataBoundControl.LoadClientState(Dictionary<string, object>)

Executed when post data is loaded from the request

C#
protected override bool LoadPostData(string postDataKey, NameValueCollection postCollection)
Parameters:postDataKeystringpostCollectionNameValueCollectionReturns:

bool

Overrides: RadDataBoundControl.LoadPostData(string, NameValueCollection)

C#
protected override void LoadViewState(object savedState)
Parameters:savedStateobject

Overrides: DataBoundControl.LoadViewState(object)

Executed right after the item is created and inserted in the Rating Items collection.

C#
protected virtual void OnItemCreated(RatingEventArgs e)
Parameters:eRatingEventArgs

Executed right after the item is data-bound to the data source.

C#
protected virtual void OnItemDataBound(RatingEventArgs e)
Parameters:eRatingEventArgs

Gets or sets a value indicating the server-side event handler that is called when the current rating of the RadRating control changes.

C#
protected virtual void OnRate(EventArgs e)
Parameters:eEventArgs

Two parameters are passed to the handler:

  • sender, the RadRating object that raised the event.
  • args.
Example:
C#
The following example demonstrates how to use the <strong>OnRate</strong> property.

<p>
    <div class="LanguageSpecific" name="Code_VB">
        &lt;telerik:RadRating ID="RadRating1" runat= "server"<br />
        <strong>OnRate="OnRate" AutoPostBack="true"</strong>&gt;<br />
        ....<br />
        &lt;/telerik:RadRating&gt;
    </div>
</p>
C#
protected override void PerformDataBinding(IEnumerable data)
Parameters:dataIEnumerable

Overrides: DataBoundControl.PerformDataBinding(IEnumerable)

C#
protected void PrepareForDataBinding()
C#
public void RaisePostBackEvent(string eventArgument)
Parameters:eventArgumentstring

Implements: IPostBackEventHandler.RaisePostBackEvent(string)

Executed when post data changes should invoke a changed event

C#
protected override void RaisePostDataChangedEvent()

Overrides: RadDataBoundControl.RaisePostDataChangedEvent()

C#
protected override void RenderContents(HtmlTextWriter writer)
Parameters:writerHtmlTextWriter

Overrides: RadDataBoundControl.RenderContents(HtmlTextWriter)

C#
protected override object SaveViewState()
Returns:

object

Overrides: DataBoundControl.SaveViewState()

C#
protected override void TrackViewState()

Overrides: DataBoundControl.TrackViewState()

Events

Adds or removes an event handler method from the ItemDataBound event. Fired after a rating item is created and inserted in the Rating Items collection.

C#
public virtual event EventHandler<RatingEventArgs> ItemCreated

Adds or removes an event handler method from the ItemDataBound event. Fired after a rating item (star) is data bound.

C#
public virtual event EventHandler<RatingEventArgs> ItemDataBound

Adds or removes an event handler method from the Rate event. Fired after a rating item (star) is clicked.

C#
public virtual event EventHandler Rate