TemplateInstance 列挙体とは? わかりやすく解説

TemplateInstance 列挙体

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

テンプレートインスタンス作成できる回数指定します

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

Dim instance As TemplateInstance
public enum TemplateInstance
public enum class TemplateInstance
public enum TemplateInstance
public enum TemplateInstance
メンバメンバ
解説解説
使用例使用例

TemplateInstance 列挙体と TemplateInstanceAttribute クラス使用方法次のコード例示しますMyLoginView という名前のカスタム LoginView コントロールが AnonymousTemplate プロパティオーバーライドして、TemplateInstanceAttribute クラスにより、AnonymousTemplate プロパティ1 回のみインスタンス生成することを指定してます。

Imports Microsoft.VisualBasic
Imports System
Imports System.Data
Imports System.ComponentModel
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls

Namespace Samples.AspNet.VB.Controls

    Public Class MyLoginView
        Inherits LoginView

        Private _anonymoustemplate As ITemplate

        <Browsable(False), DefaultValue(""),
 PersistenceMode(PersistenceMode.InnerProperty), TemplateContainer(GetType(LoginView)),
 TemplateInstance(TemplateInstance.Single)> _
        Public Overrides Property
 AnonymousTemplate() As System.Web.UI.ITemplate
            Get
                Return _anonymoustemplate
            End Get
            Set(ByVal value As
 System.Web.UI.ITemplate)
                _anonymoustemplate = value
            End Set
        End Property

    End Class

End Namespace
using System;
using System.Data;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Samples.AspNet.CS.Controls
{
    public class MyLoginView : LoginView
    {
        private ITemplate _anonymoustemplate;

        [Browsable(false),
        DefaultValue(null),
        PersistenceMode(PersistenceMode.InnerProperty),
        TemplateContainer(typeof(LoginView)),
        TemplateInstance(TemplateInstance.Single)
        ]
        public override ITemplate AnonymousTemplate
        {
            get
            {
                return _anonymoustemplate;
            }
            set
            {
                _anonymoustemplate = value;
            }
        }
    }
}

MyLoginView コントロール使用する ASPX ファイルと、AnonymousTemplate プロパティ内の Label コントロールアクセスする方法次のコード例示します

<%@ Page Language="VB" %>
<%@ Register TagPrefix="AspNetSamples" Namespace="Samples.AspNet.VB.Controls"
 Assembly="Samples.AspNet.VB.Controls"
 %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  Protected Sub Page_Load(ByVal
 sender As Object, ByVal
 e As System.EventArgs)
    
    Me.DataBind()
    Me.LoginViewLabel1.Text = "LoginView Anonymous
 Template Label Set Dynamically."

  End Sub
  
</script>

<html  >
<head runat="server">
    <title>TemplateInstance Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <AspNetSamples:MyLoginView id="MyLoginView1"
 runat="server">
        <AnonymousTemplate>
          <asp:Label ID="LoginViewLabel1" runat="server"
 Text="Test"/>
        </AnonymousTemplate>
      </AspNetSamples:MyLoginView>
    </div>
    </form>
</body>
</html>
<%@ Page Language="C#" %>
<%@ Register TagPrefix="AspNetSamples" Namespace="Samples.AspNet.CS.Controls"
 Assembly="Samples.AspNet.CS.Controls" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    
  protected void Page_Load(object sender, EventArgs
 e)
  {
    this.DataBind();
    this.LoginViewLabel1.Text = "LoginView Anonymous Template
 Label Set Dynamically.";    
  }
</script>

<html  >
<head runat="server">
    <title>TemplateInstance Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <AspNetSamples:MyLoginView id="MyLoginView1" runat="server">
        <AnonymousTemplate>
          <asp:Label ID="LoginViewLabel1" runat="server" Text="Test"/>
        </AnonymousTemplate>
      </AspNetSamples:MyLoginView>
    </div>
    </form>
</body>
</html>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
System.Web.UI 名前空間
TemplateInstanceAttribute
EditorZone.ZoneTemplate
CatalogZone.ZoneTemplate
WebPartZone.ZoneTemplate



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

辞書ショートカット

すべての辞書の索引

「TemplateInstance 列挙体」の関連用語

TemplateInstance 列挙体のお隣キーワード
検索ランキング

   

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



TemplateInstance 列挙体のページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS