更新 : 2007 年 11 月
名前空間 :
System.Web.UI アセンブリ :
System.Web (System.Web.dll 内)
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public MustInherit Class TemplateControl _
Inherits Control _
Implements INamingContainer, IFilterResolutionService
Dim instance As TemplateControl
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public abstract class TemplateControl : Control,
INamingContainer, IFilterResolutionService
[AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction::InheritanceDemand, Level = AspNetHostingPermissionLevel::Minimal)]
public ref class TemplateControl abstract : public Control,
INamingContainer, IFilterResolutionService
/** @attribute AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal) */
/** @attribute AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal) */
public abstract class TemplateControl extends Control implements INamingContainer,
IFilterResolutionService
public abstract class TemplateControl extends Control implements INamingContainer, IFilterResolutionService
TemplateControl クラスは、Page クラスと UserControl クラスに共通のプロパティとメソッドを提供する抽象クラスです。TemplateControl の新しいインスタンスを直接作成することはできません。
TemplateControl クラスは、宣言によるデータ バインディング式をサポートするメソッドを定義します。
単純なプロパティまたは式など、データ ソースを含むデータ バインディング式には Eval メソッドを使用します。
XPath データ バインディング式を解析および評価するには XPath メソッドを使用します。
XPath 選択ステートメントを含む式でのデータ バインディングに対しては XPathSelect メソッドを使用します。結果は、IEnumerable インターフェイスを実装するノード コレクションになります。
データ バインディング式の詳細については、「データ バインディング式の構文」と「データベースへのバインド」を参照してください。
TemplateControl クラスから MyControl という名前のコントロールを派生させ、Construct メソッドをオーバーライドする方法を次のコード例に示します。MyControl が初期化されると、オーバーライドされた Construct メソッドが呼び出されます。
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Security.Permissions
' The custom user control class.
<AspNetHostingPermission(SecurityAction.Demand, _
Level:=AspNetHostingPermissionLevel.Minimal)> _
Public Class MyControl
Inherits UserControl
' Create a Message property and accessors.
Private _message As String = Nothing
Public Property Message() As String
Get
Return _message
End Get
Set
_message = value
End Set
End Property
' Create an event for this user control
Public Event myControl As System.EventHandler
' Override the default constructor.
Protected Overrides Sub Construct()
' Specify the handler for the OnInit method.
AddHandler Me.myControl, AddressOf MyInit
End Sub
Protected Overrides Sub OnInit(ByVal e As EventArgs)
RaiseEvent myControl(Me, e)
Response.Write("The OnInit() method is used to raise the Init event.")
End Sub
' Use the MyInit handler to set the Message property
Sub MyInit(ByVal sender As Object, ByVal e As System.EventArgs)
Message = "Hello World!"
End Sub
' Render the value of the Message property
Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
writer.Write(("<br>Message :" & Message))
End Sub
End Class
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Permissions;
// The custom user control class.
[AspNetHostingPermission(SecurityAction.Demand,
Level = AspNetHostingPermissionLevel.Minimal)]
public class MyControl : UserControl
{
// Create a Message property and accessors.
private string _message = "No message";
public string Message
{
get { return _message; }
set { _message = value; }
}
// Create an event for this user control
public event System.EventHandler myControl;
// Override the default constructor.
protected override void Construct()
{
// Specify the handler for the OnInit method.
this.myControl += new EventHandler(MyInit);
}
protected override void OnInit(EventArgs e)
{
myControl(this, e);
Response.Write("The OnInit() method is used to raise the Init event.");
}
// Use the MyInit handler to set the Message property
void MyInit(object sender, System.EventArgs e)
{
Message = "Hello World!";
}
// Render the value of the Message property
protected override void Render(HtmlTextWriter writer)
{
writer.Write("<br>Message :" + Message);
}
}
System..::.Object
System.Web.UI..::.Control
System.Web.UI..::.TemplateControl
System.Web.UI..::.Page
System.Web.UI..::.UserControl
この型のすべてのパブリック static (Visual Basic では Shared) メンバは、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。
.NET Framework
サポート対象 : 3.5、3.0、2.0、1.1、1.0
参照