Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.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)
Visual Basic (Declaration)
<AttributeUsageAttribute(AttributeTargets.Class)> _
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class ToolboxDataAttribute _
    Inherits Attribute
Visual Basic (Usage)
Dim instance As ToolboxDataAttribute
C#
[AttributeUsageAttribute(AttributeTargets.Class)]
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class ToolboxDataAttribute : Attribute
Visual C++
[AttributeUsageAttribute(AttributeTargets::Class)]
[AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)]
public ref class ToolboxDataAttribute sealed : public Attribute
JScript
public final class ToolboxDataAttribute extends Attribute

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.

TopicLocation
Walkthrough: Developing and Using a Custom Server ControlAuthoring ASP.NET Controls
Walkthrough: Developing and Using a Custom Server ControlAuthoring ASP.NET Controls
Walkthrough: Developing and Using a Custom Server ControlBuilding Applications with Visual Web Developer
Walkthrough: Developing and Using a Custom Server ControlBuilding ASP .NET Web Applications in Visual Studio
[ 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.
    } 
  }

}

System..::.Object
  System..::.Attribute
    System.Web.UI..::.ToolboxDataAttribute
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker