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

Definicja

Rejestruje właściwość stylu i zwraca unikatowy klucz do wyszukiwania. Ten interfejs API jest nieaktualny. Aby uzyskać informacje na temat tworzenia ASP.NET aplikacji mobilnych, zobacz Mobile Apps & Sites with ASP.NET (Aplikacje mobilne & 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

Parametry

name
String

Nazwa właściwości stylu.

type
Type

Typ używany dla właściwości .

defaultValue
Object

Wartość domyślna właściwości.

inherit
Boolean

Wskazuje, czy styl dziedziczy z obiektów nadrzędnych. Wartość domyślna to true.

Zwraca

Unikatowy klucz do wyszukiwania.

Przykłady

W poniższym przykładzie pokazano, jak za pomocą RegisterStyle metody zarejestrować właściwość ciągu, która obsługuje dziedziczenie i których wartość domyślna jest pustym ciągiem (""). Ten niekompletny przykład zawiera właściwość publiczną, której implementacja uzyskuje dostęp do elementu tej właściwości przy użyciu domyślnej właściwości indeksatora klasy bazowej.

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

Uwagi

Wywoływane tylko z dziedziczynych klas stylów.

Dotyczy

Zobacz też