Style.RegisterStyle(String, Type, Object, Boolean) Metodo

Definizione

Registra una proprietà dello stile e restituisce una chiave univoca per la ricerca. Questa API è obsoleta. Per informazioni su come sviluppare applicazioni ASP.NET per dispositivi mobili, vedere App per dispositivi mobili & Siti con 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

Parametri

name
String

Nome della proprietà dello stile.

type
Type

Tipo utilizzato per la proprietà.

defaultValue
Object

Valore predefinito della proprietà.

inherit
Boolean

Indica se lo stile eredita da oggetti padre. Il valore predefinito è true.

Restituisce

Chiave univoca per la ricerca.

Esempio

Nell'esempio seguente viene illustrato come utilizzare il RegisterStyle metodo per registrare una proprietà stringa che supporta l'ereditarietà e il cui valore predefinito è una stringa vuota (""). Questo esempio incompleto include una proprietà pubblica, la cui implementazione accede a un elemento di questa proprietà usando la proprietà indicizzatore predefinita della classe base.

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

Commenti

Chiamato solo dalle classi di stile ereditate.

Si applica a

Vedi anche