MobilePage.AllowCustomAttributes Özellik

Tanım

Sayfadaki denetimlerin tanımlanmış özel özniteliklere sahip olup olmadığını belirten bir değer alır. Varsayılan değer, Web.config dosyasının <mobilecontrols> bölümünün özniteliğinin değeridir.allowCustomAttributes Bu, API artık kullanılmıyor. ASP.NET mobil uygulama geliştirme hakkında bilgi için bkz. ASP.NET ile Mobile Apps & Siteleri.

public:
 property bool AllowCustomAttributes { bool get(); void set(bool value); };
[System.ComponentModel.Bindable(false)]
[System.ComponentModel.Browsable(false)]
public bool AllowCustomAttributes { get; set; }
[<System.ComponentModel.Bindable(false)>]
[<System.ComponentModel.Browsable(false)>]
member this.AllowCustomAttributes : bool with get, set
Public Property AllowCustomAttributes As Boolean

Özellik Değeri

true sayfadaki denetimlerin tanımlanmış özel öznitelikleri varsa; aksi takdirde , false.

Öznitelikler

Örnekler

Aşağıdaki örnekte, üzerinde özel AccessKey özniteliği etkinleştirmek için özelliğinin nasıl kullanılacağı AllowCustomAttributes gösterilmektedirCommand.

Not

Aşağıdaki kod örneği tek dosyalı kod modelini kullanır ve doğrudan arka planda kod dosyasına kopyalarsanız düzgün çalışmayabilir. Bu kod örneğini .aspx uzantısına sahip boş bir metin dosyasına kopyalamanız gerekir. Daha fazla bilgi için bkz. ASP.NET Web Forms Sayfa Kodu Modeli.

<%@ Page Language="C#" 
    Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls" 
    Assembly="System.Web.Mobile" %>
<%@ Import Namespace="System.Web.Mobile" %>

<script runat="server">
    // <Snippet2>
    private void Command_OnClick(object sender, EventArgs e)
    {
        // Display the other form
        if (ActiveForm.ID == "Form1")
            ActiveForm = Form2;
        else
            ActiveForm = Form1;
    }
    // </Snippet2>

    public bool isAccessKey(MobileCapabilities caps, 
        string optValue)
    {
        // Determine if the browser is not a Web crawler 
        // and can use access keys
        if (!caps.Crawler && caps.SupportsAccesskeyAttribute)
            return true;
        return false;
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
    <mobile:Form runat="server" id="Form1" >
        <mobile:Label Runat="server">This is Form1</mobile:Label>
        <mobile:Command id="cmd1" runat="server" Text="No AccessKey" 
            onClick="Command_OnClick">
            <DeviceSpecific>
               <Choice Filter="isAccessKey" Text="AccessKey is 1"/>
            </DeviceSpecific>
        </mobile:Command>
        <mobile:Label id="Label1" runat="server" />
    </mobile:Form>
    <mobile:Form ID="Form2" Runat="server">
        <mobile:Label Runat="server">This is Form2</mobile:Label>
        <mobile:Command id="cmd2" runat="server" text="Back to Form1"
            onClick="Command_OnClick">
            <DeviceSpecific>
                <Choice Filter="isAccessKey" Text="1 is AccessKey" AccessKey="1" />
            </DeviceSpecific>
        </mobile:Command>
    </mobile:Form>
</body>
</html>
<%@ Page Language="VB" 
    Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile" 
    Namespace="System.Web.UI.MobileControls" 
    Assembly="System.Web.Mobile" %>
<%@ Import Namespace="System.Web.Mobile" %>

<script runat="server">
    ' <Snippet2>
    Private Sub Command_OnClick(ByVal sender As Object, ByVal e As EventArgs)
        ' Display the other form
        If ActiveForm.ID = "Form1" Then
            ActiveForm = Form2
        Else
            ActiveForm = Form1
        End If
    End Sub
    ' </Snippet2>

    Public Function isAccessKey(ByVal caps As MobileCapabilities, _
        ByVal optValue As String) As Boolean
        
        ' Determine if the browser is not a Web crawler 
        ' and can use access keys
        If Not caps.Crawler AndAlso caps.SupportsAccesskeyAttribute Then
            Return True
        End If
        Return False
    End Function

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
    <mobile:Form runat="server" id="Form1" >
        <mobile:Label ID="Label1" Runat="server">This is Form1</mobile:Label>
        <mobile:Command id="cmd1" runat="server" Text="No AccessKey" 
            onClick="Command_OnClick">
            <DeviceSpecific>
               <Choice Filter="isAccessKey" Text="AccessKey is 1"/>
            </DeviceSpecific>
        </mobile:Command>
        <mobile:Label id="Label2" runat="server" />
    </mobile:Form>
    <mobile:Form ID="Form2" Runat="server">
        <mobile:Label ID="Label3" Runat="server">This is Form2</mobile:Label>
        <mobile:Command id="cmd2" runat="server" text="Back to Form1"
            onClick="Command_OnClick">
            <DeviceSpecific>
                <Choice Filter="isAccessKey" Text="1 is AccessKey" AccessKey="1" />
            </DeviceSpecific>
        </mobile:Command>
    </mobile:Form>
</body>
</html>

Açıklamalar

arabirime IAttributeAccessor ek olarak, ASP.NET sayfa çerçevesi ek öznitelikler belirtmenize, özel dağıtmayı etkinleştirmenize veya devre dışı bırakmanıza ya da denetimin davranışını veya işlemesini ayarlamanıza olanak tanıyan bir sözlük sağlar CustomAttributes . Özel dağıtımı etkinleştirmek veya devre dışı bırakmak için özelliğini olarak ayarlayabilir AllowCustomAttributes veya Web.config bölümünün özniteliğini <mobileControls> olarak trueayarlayabilirsinizallowCustomAttributes.true

Not

Özel öznitelikler etkinleştirildiğinde, özellik adlarındaki tipografik hatalar özel öznitelikler olarak yorumlanabilir. Örneğin, bir geliştirici denetimin Text özelliğini yanlış bir şekilde "Txet" olarak belirtiyorsa, ayrıştırıcı bunu özel durum oluşturmak yerine "Txet" adlı özel bir öznitelik olarak kaydeder. Bu nedenle, özel öznitelikler varsayılan olarak devre dışı bırakılır.

Şunlara uygulanır

Ayrıca bkz.