Style.RegisterStyle(String, Type, Object, Boolean) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Registers a style property and returns a unique key for lookup. This API is obsolete. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.
public:
static System::Object ^ RegisterStyle(System::String ^ name, Type ^ type, System::Object ^ defaultValue, bool inherit);
public static object RegisterStyle (string name, Type type, object defaultValue, bool inherit);
static member RegisterStyle : string * Type * obj * bool -> obj
Public Shared Function RegisterStyle (name As String, type As Type, defaultValue As Object, inherit As Boolean) As Object
Parameters
- name
- String
The name of the style property.
- type
- Type
The type used for the property.
- defaultValue
- Object
The default value of the property.
- inherit
- Boolean
Indicates whether the style inherits from parent objects. The default is true
.
Returns
A unique key for lookup.
Examples
The following example demonstrates how to use the RegisterStyle method to register a string property that supports inheritance and whose default value is an empty string (""). This incomplete example includes a public property, whose implementation accesses an element of this property by using the default indexer property of the base class.
public class CustomStyle :
System.Web.UI.MobileControls.Style
{
private string themeNameKey;
public CustomStyle(string name)
{
themeNameKey =
RegisterStyle(name, typeof(String),
String.Empty, true).ToString();
}
public string ThemeName
{
get
{
return this[themeNameKey].ToString();
}
set
{
this[themeNameKey] = value;
}
}
}
Public Class CustomStyle
Inherits System.Web.UI.MobileControls.Style
Private themeNameKey As String
Public Sub New(ByVal name As String)
themeNameKey = _
RegisterStyle(name, GetType(String), _
String.Empty, True).ToString()
End Sub
Public Property ThemeName() As String
Get
Return Me(themeNameKey).ToString()
End Get
Set(ByVal value As String)
Me(themeNameKey) = value
End Set
End Property
End Class
Remarks
Called only from inherited style classes.