ToolboxDataAttribute クラス
アセンブリ: System.Web (system.web.dll 内)
構文
<AttributeUsageAttribute(AttributeTargets.Class)> _ Public NotInheritable Class ToolboxDataAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Class)] public sealed class ToolboxDataAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class)] public ref class ToolboxDataAttribute sealed : public Attribute
既定では、Visual Studio などのツールのビジュアル デザイナで、空のタグが作成されます。このタグは、コントロールをビジュアル デザイナのツールボックスからデザイン サーフェイスにドロップするときの、既定の状態のコントロールを表すタグです。初期既定値を指定する場合、コントロールはこの属性を利用できます。この属性を使用すると、コントロールがツールボックスからフォームにドラッグされるときにデザイナに配置される初期の HTML の内容をカスタマイズできます。
[ ToolboxData("<{0}:MyLabel runat= server Text= MyLabel><{0}:MyLabel>") ]public class MyLabel : Label {...}
上記のコードによって MyLabel に固有のプロパティをいくつか設定する例を次に示します。すべての {0} が、デザイナによって、MyLabel クラスに関連付けられているタグ プリフィックスに置換されます。
Imports System Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls Namespace CustomControls <ToolboxData("<{0}:MyLabel Text='MyLabel' BorderColor='Yellow' BackColor='Magenta' BorderWidth = '10' runat='server'></{0}:MyLabel>")> _ Public Class MyLabel Inherits Label Public Sub New() 'Your code goes here. End Sub 'New End Class 'MyLabel End Namespace 'CustomControls
using System; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace CustomControls { [ ToolboxData("<{0}:MyLabel Text='MyLabel' BorderColor='Yellow' BackColor='Magenta' BorderWidth = '10' runat='server'></{0}:MyLabel>") ] public class MyLabel : Label { public MyLabel() { // Your code goes here. } } }
import System.*; import System.Web.*; import System.Web.UI.*; import System.Web.UI.WebControls.*; /** @attribute ToolboxData("<{0}:MyLabel Text='MyLabel' BorderColor='Yellow'" + "BackColor='Magenta' BorderWidth = '10' runat='server'></{0}:MyLabel>") */ public class MyLabel extends Label { public MyLabel() { // Your code goes here. } //MyLabel } //MyLabel
System.Attribute
System.Web.UI.ToolboxDataAttribute
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- ToolboxDataAttribute クラスのページへのリンク