TemplateInstanceAttribute.IsDefaultAttribute メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > TemplateInstanceAttribute.IsDefaultAttribute メソッドの意味・解説 

TemplateInstanceAttribute.IsDefaultAttribute メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

現在の TemplateInstanceAttribute オブジェクト既定TemplateInstanceAttribute オブジェクトと同じかどうかを示す値を返します

名前空間: System.Web.UI
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Overrides Function
 IsDefaultAttribute As Boolean
Dim instance As TemplateInstanceAttribute
Dim returnValue As Boolean

returnValue = instance.IsDefaultAttribute
public override bool IsDefaultAttribute ()
public:
virtual bool IsDefaultAttribute () override
public boolean IsDefaultAttribute ()
public override function IsDefaultAttribute
 () : boolean

戻り値
TemplateInstanceAttribute現在のインスタンスの値が既定値である場合trueそれ以外場合false

解説解説

TemplateInstanceAttribute クラス既定値Multiple フィールドです。

使用例使用例

IsDefaultAttribute メソッド使用する方法次のコード例示しますASPX ページPage_Load イベントで、MyLoginViewA カスタム コントロールAnonymousTemplate プロパティTemplateInstanceAttribute クラス照会されます

MyLoginViewA コントロール定義については、TemplateInstanceAttributeトピック参照してください

Protected Sub Page_Load(ByVal
 sender As Object, ByVal
 e As System.EventArgs)
  
  ' Get the class type for which to access metadata.
  Dim clsType As Type = GetType(MyLoginViewA)
  ' Get the PropertyInfo object for FirstTemplate.
  Dim pInfo As PropertyInfo = clsType.GetProperty("AnonymousTemplate")
  ' See if the TemplateInstanceAttribute is defined for this property.
  Dim isDef As Boolean =
 Attribute.IsDefined(pInfo, GetType(TemplateContainerAttribute))
  
  ' Display the result if the attribute exists.
  If isDef Then
    Dim tia As TemplateInstanceAttribute =
 CType(Attribute.GetCustomAttribute(pInfo, GetType(TemplateInstanceAttribute)),
 TemplateInstanceAttribute)
    Response.Write("The <AnonymousTemplate> has the TemplateInstanceAttribute
 = " & tia.Instances.ToString() & ".<br>")
    If (tia.IsDefaultAttribute()) Then
      Response.Write("The TemplateInstanceAttribute used is the
 same as the default instance.")
    Else
      Response.Write("The TemplateInstanceAttribute used is not
 the same as the default instance.")
    End If

  End If

End Sub
protected void Page_Load(object sender, EventArgs
 e)
{
      
  // Get the class type for which to access metadata.
  Type clsType = typeof(MyLoginViewA);
  // Get the PropertyInfo object for FirstTemplate.
  PropertyInfo pInfo = clsType.GetProperty("AnonymousTemplate");
  // See if the TemplateInstanceAttribute is defined for this property.
  bool isDef = Attribute.IsDefined(pInfo, typeof(TemplateInstanceAttribute));

  // Display the result if the attribute exists.
  if (isDef)
  {
    TemplateInstanceAttribute tia =
      (TemplateInstanceAttribute)Attribute.GetCustomAttribute(pInfo, typeof(TemplateInstanceAttribute));
    Response.Write("The <AnonymousTemplate> has the TemplateInstanceAttribute
 = " + tia.Instances.ToString() + ".<br>");
    if (tia.IsDefaultAttribute())
      Response.Write("The TemplateInstanceAttribute used is the same as the
 default instance.");
    else
      Response.Write("The TemplateInstanceAttribute used is not the same as
 the default instance.");
  }

}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TemplateInstanceAttribute クラス
TemplateInstanceAttribute メンバ
System.Web.UI 名前空間
Equals
Multiple



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

TemplateInstanceAttribute.IsDefaultAttribute メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



TemplateInstanceAttribute.IsDefaultAttribute メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS