Specifies the default property of a control that a ControlParameter object binds to at run time. This class cannot be inherited.
Assembly: System.Web (in System.Web.dll)
<AttributeUsageAttribute(AttributeTargets.Class)> _ <AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _ Public NotInheritable Class ControlValuePropertyAttribute _ Inherits Attribute
Dim instance As ControlValuePropertyAttribute
[AttributeUsageAttribute(AttributeTargets.Class)] [AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)] public sealed class ControlValuePropertyAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class)] [AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)] public ref class ControlValuePropertyAttribute sealed : public Attribute
public final class ControlValuePropertyAttribute extends Attribute
When defining a ControlParameter object, you typically bind a control's property to a parameter by setting both the ControlID and PropertyName properties. If the PropertyName property is not set, a default property is used. The ControlValuePropertyAttribute attribute is applied to a control to specify its default property that a ControlParameter object binds to at run time.
For more information about using attributes, see Extending Metadata Using Attributes.
For a list of initial property values for an instance of the ControlValuePropertyAttribute class, see the ControlValuePropertyAttribute constructor.
The following code example demonstrates how to apply a ControlValuePropertyAttribute attribute that specifies a default property and value to a custom control.
Imports System.ComponentModel Imports System.Web.UI Namespace Samples.AspNet.VB.Controls ' Set ControlValueProperty attribute to specify the default ' property of this control that a ControlParameter object ' binds to at run time. <DefaultProperty("Text"), ControlValueProperty("Text", "DefaultText")> Public Class SimpleCustomControl Inherits System.Web.UI.WebControls.WebControl Dim _text As String <Bindable(True), Category("Appearance"), DefaultValue("")> Property [Text]() As String Get Return _text End Get Set(ByVal Value As String) _text = Value End Set End Property Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter) output.Write([Text]) End Sub End Class End Namespace
using System; using System.Collections.Generic; using System.ComponentModel; using System.Text; using System.Web.UI; using System.Web.UI.WebControls; namespace Samples.AspNet.CS.Controls { // Set ControlValueProperty attribute to specify the default // property of this control that a ControlParameter object // binds to at run time. [DefaultProperty("Text")] [ControlValueProperty("Text", "Default Text")] public class SimpleCustomControl : WebControl { private string text; [Bindable(true)] [Category("Appearance")] [DefaultValue("")] public string Text { get { return text; } set { text = value; } } protected override void Render(HtmlTextWriter output) { output.Write(Text); } } }
-
AspNetHostingPermission
for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
System.Attribute
System.Web.UI.ControlValuePropertyAttribute
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.