This topic has not yet been rated - Rate this topic

RatingScaleField Class

Represents a control for a rating scale field in surveys.

Namespace:  Microsoft.SharePoint.WebControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class RatingScaleField : BaseFieldControl
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
RatingScaleField
Description 

The Microsoft.SharePoint.WebControls.RatingScaleField class inherits from the Microsoft.SharePoint.WebControls.BaseFieldControl class which represents a field through the use of child controls on a form page within SharePoint. RatingScaleField is used within the shipped software as a support field for surveys in order to provide user defined ratings through System.Web.UI.WebControls.RadioButton controls. The number of RadioButton controls used is determined by the number of choices. The Microsoft.SharePoint.SPFieldRatingScaleValue class is used to represent values, and the Microsoft.SharePoint.SPFieldRatingScale is corresponds to a rating scale field type.

Usage Scenario 

The primary usage of RatingScaleField is to support shipped SharePoint survey functionality, and is rarely used otherwise unless extending native survey operations with a custom field type. However, as an orthodox SharePoint field control it is feasible to use in a customary field fashion due to the control reliance of Microsoft.SharePoint.WebControls.BaseFieldControl for inheritance. 

In the below example, the MyClass class inherits from Microsoft.SharePoint.SPFieldMultiChoice, implementing the appropriate constructors with relevant parameters when required. Following, there is overriding of the FieldRenderingControl property. Next, a new Microsoft.SharePoint.WebControls.BaseFieldControl object is being created set to instantiate as a Microsoft.SharePoint.WebControls.RatingScaleField type. Following, the BaseFieldControl.FieldName property is being set to the SPField.InternalName property, and the control is being returned.

C# Code Example 

public class MyClass : SPFieldMultiChoice

public MyClass(SPFieldCollection fields, string fieldName) : base(fields, fieldName)
{

public MyClass(SPFieldCollection fields, string typeName, string displayName) : base(fields, typeName, displayName)
{
}
public override BaseFieldControl FieldRenderingControl
{
get
{
BaseFieldControl control = new RatingScaleField();
control.FieldName = InternalName;
return control;
}
}
}

VB.NET Code Example 

Public Class [MyClass]
Inherits SPFieldMultiChoice
Public Sub New(ByVal fields As SPFieldCollection, ByVal fieldName As String)
MyBase.New(fields, fieldName)
End Sub
Public Sub New(ByVal fields As SPFieldCollection, ByVal typeName As String, ByVal displayName As String)
MyBase.New(fields, typeName, displayName)
End Sub
Public Overloads Overrides ReadOnly Property FieldRenderingControl() As BaseFieldControl
Get
Dim control As BaseFieldControl = New RatingScaleField()
control.FieldName = InternalName
Return control
End Get
End Property
End Class

Adam Buenz
SharePoint Foundation MVP - http://www.sharepointsecurity.com