다음을 통해 공유


MobilePage.AllowCustomAttributes 속성

정의

페이지의 컨트롤에 사용자 지정 특성이 정의될 수 있는지 여부를 나타내는 값을 가져옵니다. 기본값은 Web.config 파일에서 <mobilecontrols> 섹션의 allowCustomAttributes 특성 값입니다. 이 API는 더 이상 사용되지 않습니다. ASP.NET 모바일 애플리케이션을 개발하는 방법에 대한 자세한 내용은 ASP.NET 있는 Mobile Apps & 사이트를 참조하세요.

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

속성 값

페이지의 컨트롤에 사용자 지정 특성이 정의될 수 있으면 true이고, 그렇지 않으면 false입니다.

특성

예제

다음 예제에서는 사용 AllowCustomAttributes 하는 방법에 설명 합니다 에서 사용자 지정 AccessKey 특성을 사용 하도록 설정 하는 속성입니다 Command.

참고

다음 코드 샘플에서는 단일 파일 코드 모델을 사용하며 코드 숨김 파일에 직접 복사하는 경우 제대로 작동하지 않을 수 있습니다. 이 코드 샘플을 확장명 .aspx가 있는 빈 텍스트 파일에 복사해야 합니다. 자세한 내용은 ASP.NET Web Forms 페이지 코드 모델합니다.

<%@ 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>

설명

인터페이스 외에도 IAttributeAccessor ASP.NET 페이지 프레임워크는 추가 특성을 지정하거나, 사용자 지정 특성을 사용하거나 사용하지 않도록 설정하거나, 컨트롤의 동작 또는 렌더링을 조정할 수 있는 사전을 제공합니다 CustomAttributes . 사용자 지정 특성 지정을 사용하거나 사용하지 않도록 설정하려면 속성을 로 설정 AllowCustomAttributes 하거나 Web.config true섹션의 <mobileControls> 특성을 로 설정할 allowCustomAttributestrue있습니다.

참고

사용자 지정 특성을 사용하도록 설정하면 속성 이름의 입력 오류를 사용자 지정 특성으로 해석할 수 있습니다. 예를 들어 개발자가 컨트롤의 속성을 "Txet"으로 잘못 지정 Text 하면 파서는 예외를 발생시키는 대신 "Txet"이라는 사용자 지정 특성으로 저장합니다. 이러한 이유로 사용자 지정 특성은 기본적으로 사용하지 않도록 설정됩니다.

적용 대상

추가 정보