ControlValuePropertyAttribute Constructores
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Inicializa una nueva instancia de la clase ControlValuePropertyAttribute.
Sobrecargas
| Nombre | Description |
|---|---|
| ControlValuePropertyAttribute(String) |
Inicializa una nueva instancia de la ControlValuePropertyAttribute clase utilizando el nombre de propiedad especificado. |
| ControlValuePropertyAttribute(String, Object) |
Inicializa una nueva instancia de la ControlValuePropertyAttribute clase utilizando el nombre de propiedad y el valor predeterminado especificados. |
| ControlValuePropertyAttribute(String, Type, String) |
Inicializa una nueva instancia de la ControlValuePropertyAttribute clase utilizando el nombre de propiedad y el valor predeterminado especificados. El valor predeterminado también se convierte en el tipo de datos especificado. |
ControlValuePropertyAttribute(String)
Inicializa una nueva instancia de la ControlValuePropertyAttribute clase utilizando el nombre de propiedad especificado.
public:
ControlValuePropertyAttribute(System::String ^ name);
public ControlValuePropertyAttribute(string name);
new System.Web.UI.ControlValuePropertyAttribute : string -> System.Web.UI.ControlValuePropertyAttribute
Public Sub New (name As String)
Parámetros
- name
- String
Propiedad predeterminada del control.
Ejemplos
En el ejemplo de código siguiente se muestra cómo aplicar un ControlValuePropertyAttribute atributo que especifica una propiedad predeterminada a un control personalizado. El ASP.NET llama a este constructor internamente para crear un ControlValuePropertyAttribute objeto que represente el atributo .
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")]
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);
}
}
}
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")> 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
Comentarios
Use este constructor para crear una nueva instancia de la ControlValuePropertyAttribute clase mediante el nombre de propiedad especificado. En la tabla siguiente se muestra el valor de propiedad inicial de una instancia de la ControlValuePropertyAttribute clase .
| Propiedad | Valor inicial |
|---|---|
| Name | Valor del name parámetro . |
Consulte también
Se aplica a
ControlValuePropertyAttribute(String, Object)
Inicializa una nueva instancia de la ControlValuePropertyAttribute clase utilizando el nombre de propiedad y el valor predeterminado especificados.
public:
ControlValuePropertyAttribute(System::String ^ name, System::Object ^ defaultValue);
public ControlValuePropertyAttribute(string name, object defaultValue);
new System.Web.UI.ControlValuePropertyAttribute : string * obj -> System.Web.UI.ControlValuePropertyAttribute
Public Sub New (name As String, defaultValue As Object)
Parámetros
- name
- String
Propiedad predeterminada del control.
- defaultValue
- Object
Valor predeterminado de la propiedad predeterminada.
Ejemplos
En el ejemplo de código siguiente se muestra cómo aplicar un atributo que especifica una ControlValuePropertyAttribute propiedad y un valor predeterminados a un control personalizado. El ASP.NET llama a este constructor internamente para crear un ControlValuePropertyAttribute objeto que represente el atributo .
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);
}
}
}
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
Comentarios
Use este constructor para crear una nueva instancia de la ControlValuePropertyAttribute clase mediante el nombre de propiedad y el valor predeterminado especificados. En la tabla siguiente se muestran los valores de propiedad iniciales de una instancia de la ControlValuePropertyAttribute clase .
| Propiedad | Valor inicial |
|---|---|
| Name | Valor del name parámetro . |
| DefaultValue | Valor del defaultValue parámetro . |
Consulte también
Se aplica a
ControlValuePropertyAttribute(String, Type, String)
Inicializa una nueva instancia de la ControlValuePropertyAttribute clase utilizando el nombre de propiedad y el valor predeterminado especificados. El valor predeterminado también se convierte en el tipo de datos especificado.
public:
ControlValuePropertyAttribute(System::String ^ name, Type ^ type, System::String ^ defaultValue);
public ControlValuePropertyAttribute(string name, Type type, string defaultValue);
new System.Web.UI.ControlValuePropertyAttribute : string * Type * string -> System.Web.UI.ControlValuePropertyAttribute
Public Sub New (name As String, type As Type, defaultValue As String)
Parámetros
- name
- String
Propiedad predeterminada del control.
- defaultValue
- String
Valor predeterminado de la propiedad predeterminada.
Comentarios
Use este constructor para crear una nueva instancia de la ControlValuePropertyAttribute clase mediante el nombre de propiedad y el valor predeterminado especificados. Esta versión del constructor también intenta convertir el valor predeterminado en el tipo de datos especificado por el type parámetro . Si no se puede convertir el valor predeterminado, la DefaultValue propiedad no se establece. En la tabla siguiente se muestran los valores de propiedad iniciales de una instancia de la ControlValuePropertyAttribute clase .
| Propiedad | Valor inicial |
|---|---|
| Name | Valor del name parámetro . |
| DefaultValue | Valor del defaultValue parámetro , si el valor se puede convertir al tipo de datos especificado por el type parámetro . |