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



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

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

   

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



TemplateInstanceAttribute.IsDefaultAttribute メソッドのページの著作権

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

©2026 GRAS Group, Inc.RSS