MobilePage.AllowCustomAttributes プロパティ
アセンブリ: System.Web.Mobile (system.web.mobile.dll 内)

Dim instance As MobilePage Dim value As Boolean value = instance.AllowCustomAttributes instance.AllowCustomAttributes = value
[BindableAttribute(false)] public: property bool AllowCustomAttributes { bool get (); void set (bool value); }
/** @property */ public boolean get_AllowCustomAttributes () /** @property */ public void set_AllowCustomAttributes (boolean value)
public function get AllowCustomAttributes () : boolean public function set AllowCustomAttributes (value : boolean)
ページ上のコントロールにカスタム属性を定義できる場合はtrue。それ以外の場合は false。

ASP.NET ページ フレームワークには、IAttributeAccessor インターフェイスの他に、CustomAttributes ディクショナリが用意されています。このディクショナリを使用すると、追加属性の指定、カスタム属性の有効と無効の切り替え、コントロールの動作またはレンダリングの調整を行うことができます。カスタム属性の有効と無効を切り替えるには、AllowCustomAttributes プロパティを true に設定するか、Web.config の <mobileControls> セクションにある allowCustomAttributes 属性を true に設定します。
![]() |
---|
カスタム属性を有効にすると、プロパティ名の入力ミスがカスタム属性と解釈されることがあります。たとえば、開発者がコントロールの Text プロパティを誤って "Txet" と入力しても、例外は発生せず、"Txet" という名前のカスタム属性として保存されてしまいます。この理由から、カスタム属性は既定で無効になっています。 |

AllowCustomAttributes プロパティを使用して、Command のカスタム AccessKey 属性を有効にする方法の例を次に示します。
![]() |
---|
次のコード サンプルはシングルファイル コード モデルを使用しており、分離コード ファイルに直接コピーされた場合は正常に動作しない可能性があります。このコード サンプルは、拡張子が .aspx の空のテキスト ファイルにコピーする必要があります。詳細については、「ASP.NET Web ページのコード モデル」を参照してください。 |
<%@ 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"> 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 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 > <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>
<%@ 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"> private void Command_OnClick(object sender, EventArgs e) { // Display the other form if (ActiveForm.ID == "Form1") ActiveForm = Form2; else ActiveForm = Form1; } 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 > <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>

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からMobilePage.AllowCustomAttributes プロパティを検索する場合は、下記のリンクをクリックしてください。

- MobilePage.AllowCustomAttributes プロパティのページへのリンク