ToolboxDataAttribute Class (System.Web.UI)

Switch View :
ScriptFree
.NET Framework Class Library
ToolboxDataAttribute Class

Specifies the default tag generated for a custom control when it is dragged from a toolbox in a tool such as Microsoft Visual Studio.

Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)

Syntax

Visual Basic (Declaration)
<AttributeUsageAttribute(AttributeTargets.Class)> _
Public NotInheritable Class ToolboxDataAttribute
	Inherits Attribute
Visual Basic (Usage)
Dim instance As ToolboxDataAttribute

C#
[AttributeUsageAttribute(AttributeTargets.Class)] 
public sealed class ToolboxDataAttribute : Attribute
C++
[AttributeUsageAttribute(AttributeTargets::Class)] 
public ref class ToolboxDataAttribute sealed : public Attribute
J#
/** @attribute AttributeUsageAttribute(AttributeTargets.Class) */ 
public final class ToolboxDataAttribute extends Attribute
JScript
AttributeUsageAttribute(AttributeTargets.Class) 
public final class ToolboxDataAttribute extends Attribute
Remarks

By default, the visual designer of a tool such as Visual Studio, creates an empty tag. This is a tag representing a control in its default state, when the control is dropped from the toolbox of a visual designer onto the design surface. To specify initial default values, a control can make use of this attribute. You can use this attribute to customize the initial HTML content that is placed in the designer when the control is dragged from the toolbox onto the form.

Example

[ ToolboxData("<{0}:MyLabel runat= server Text= 
       MyLabel><{0}:MyLabel>") ]public class MyLabel : Label {...}

In the following code example, the previous code sets several properties specific to MyLabel. All occurrences of {0} are replaced, by the designer, with the tag prefix associated with the MyLabel class.

Visual Basic
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



C#

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.
    } 
  }

}


J#
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

Inheritance Hierarchy

System.Object
   System.Attribute
    System.Web.UI.ToolboxDataAttribute
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms

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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

Version Information

.NET Framework

Supported in: 2.0, 1.1, 1.0
See Also