Try our conversational search powered by Generative AI!

Class PropertySettingsAttribute

Attibute to specify a settings object for Properties and PropertyControls.

Inheritance
System.Object
System.Attribute
PropertySettingsAttribute
Implements
System.Runtime.InteropServices._Attribute
Inherited Members
System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo, System.Type)
System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo, System.Type, System.Boolean)
System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo)
System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo, System.Boolean)
System.Attribute.IsDefined(System.Reflection.MemberInfo, System.Type)
System.Attribute.IsDefined(System.Reflection.MemberInfo, System.Type, System.Boolean)
System.Attribute.GetCustomAttribute(System.Reflection.MemberInfo, System.Type)
System.Attribute.GetCustomAttribute(System.Reflection.MemberInfo, System.Type, System.Boolean)
System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo)
System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo, System.Type)
System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo, System.Type, System.Boolean)
System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo, System.Boolean)
System.Attribute.IsDefined(System.Reflection.ParameterInfo, System.Type)
System.Attribute.IsDefined(System.Reflection.ParameterInfo, System.Type, System.Boolean)
System.Attribute.GetCustomAttribute(System.Reflection.ParameterInfo, System.Type)
System.Attribute.GetCustomAttribute(System.Reflection.ParameterInfo, System.Type, System.Boolean)
System.Attribute.GetCustomAttributes(System.Reflection.Module, System.Type)
System.Attribute.GetCustomAttributes(System.Reflection.Module)
System.Attribute.GetCustomAttributes(System.Reflection.Module, System.Boolean)
System.Attribute.GetCustomAttributes(System.Reflection.Module, System.Type, System.Boolean)
System.Attribute.IsDefined(System.Reflection.Module, System.Type)
System.Attribute.IsDefined(System.Reflection.Module, System.Type, System.Boolean)
System.Attribute.GetCustomAttribute(System.Reflection.Module, System.Type)
System.Attribute.GetCustomAttribute(System.Reflection.Module, System.Type, System.Boolean)
System.Attribute.GetCustomAttributes(System.Reflection.Assembly, System.Type)
System.Attribute.GetCustomAttributes(System.Reflection.Assembly, System.Type, System.Boolean)
System.Attribute.GetCustomAttributes(System.Reflection.Assembly)
System.Attribute.GetCustomAttributes(System.Reflection.Assembly, System.Boolean)
System.Attribute.IsDefined(System.Reflection.Assembly, System.Type)
System.Attribute.IsDefined(System.Reflection.Assembly, System.Type, System.Boolean)
System.Attribute.GetCustomAttribute(System.Reflection.Assembly, System.Type)
System.Attribute.GetCustomAttribute(System.Reflection.Assembly, System.Type, System.Boolean)
System.Attribute.Equals(System.Object)
System.Attribute.GetHashCode()
System.Attribute.Match(System.Object)
System.Attribute.IsDefaultAttribute()
System.Attribute.System.Runtime.InteropServices._Attribute.GetTypeInfoCount(System.UInt32)
System.Attribute.System.Runtime.InteropServices._Attribute.GetTypeInfo(System.UInt32, System.UInt32, System.IntPtr)
System.Attribute.System.Runtime.InteropServices._Attribute.GetIDsOfNames(System.Guid, System.IntPtr, System.UInt32, System.UInt32, System.IntPtr)
System.Attribute.System.Runtime.InteropServices._Attribute.Invoke(System.UInt32, System.Guid, System.UInt32, System.Int16, System.IntPtr, System.IntPtr, System.IntPtr, System.IntPtr)
System.Attribute.TypeId
System.Object.ToString()
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Core.PropertySettings
Assembly: EPiServer.dll
Version: 11.20.7
Syntax
[AttributeUsage(AttributeTargets.Class)]
public sealed class PropertySettingsAttribute : Attribute, _Attribute
Remarks

Use this attibute to specify properties or property controls that need to store settings on the page definition level.

Examples

Simple example of marking a property control with a settings attibute:

    [PropertySettings(typeof(SamplePropertySettings), true)]
public class SamplePropertyControlWithSettings : PropertyTextBoxControlBase
{
protected override void SetupEditControls()
{
    EditControl.Text = ToString();
SamplePropertySettings settings = (SamplePropertySettings)PropertyData.GetSetting(typeof(SamplePropertySettings));
EditControl.Width = settings.Width;

} }

You can then use it together with a EPiServer.Core.PropertySettings.PropertySettingsUIAttribute:

    /// <summary>
/// Used to render a UI for editing the settings in the admin UI.
/// Needs to be in the inherit from <see cref="Control"/> and implement <see cref="IPropertySettingsUI"/>.
/// Most easily accomplished using <see cref="PropertySettingsUIBase"/>
/// </summary>
public class SettingsUISample : PropertySettingsControlBase
{
private TextBox _widthInput;

#region IPropertySettingsUI Members

protected override void CreateChildControls() { base.CreateChildControls();

_widthInput = new TextBox { ID = &quot;WidthValue&quot; };
Label label = new Label { Text = &quot;Width&quot;, AssociatedControlID = &quot;WidthValue&quot; };

Controls.Add(label);
Controls.Add(_widthInput);

}

public override void LoadSettingsUI(IPropertySettings propertySettings) { EnsureChildControls(); _widthInput.Text = ((SamplePropertySettings)propertySettings).Width.ToString(); }

public override void UpdateSettings(IPropertySettings propertySettings) { EnsureChildControls(); ((SamplePropertySettings)propertySettings).Width = int.Parse(_widthInput.Text); }

#endregion }

Constructors

PropertySettingsAttribute(Type)

Initializes a new instance of the PropertySettingsAttribute class.

Declaration
public PropertySettingsAttribute(Type settingsType)
Parameters
Type Name Description
System.Type settingsType

Type of settings entity to use.

PropertySettingsAttribute(Type, Boolean)

Initializes a new instance of the PropertySettingsAttribute class.

Declaration
public PropertySettingsAttribute(Type settingsType, bool useGlobals)
Parameters
Type Name Description
System.Type settingsType

Type of settings entity to use.

System.Boolean useGlobals

if set to true enable multiple global settings to choose from in the admin UI.

Properties

SettingsType

Gets or sets the type of settings entity.

Declaration
public Type SettingsType { get; set; }
Property Value
Type Description
System.Type

The type of the settings.

UseGlobals

Gets or sets a value indicating whether to enable multiple global settings to choose from in the admin UI.

Declaration
public bool UseGlobals { get; set; }
Property Value
Type Description
System.Boolean

true if enabled; otherwise, false.

Methods

TryGetAttribute(Type, out PropertySettingsAttribute)

Tries to get a PropertySettingsAttribute from a type.

Declaration
public static bool TryGetAttribute(Type type, out PropertySettingsAttribute attribute)
Parameters
Type Name Description
System.Type type

The type.

PropertySettingsAttribute attribute

The attribute to set if succesfull.

Returns
Type Description
System.Boolean

true if an attribute was found.

Implements

System.Runtime.InteropServices._Attribute

Extension Methods