TemplateInstanceAttribute.Instances TemplateInstanceAttribute.Instances TemplateInstanceAttribute.Instances TemplateInstanceAttribute.Instances Property

Definición

Obtiene el valor de enumeración TemplateInstance que representa la instancia de la plantilla actual.Gets the TemplateInstance enumeration value that the current template instance represents.

public:
 property System::Web::UI::TemplateInstance Instances { System::Web::UI::TemplateInstance get(); };
public System.Web.UI.TemplateInstance Instances { get; }
member this.Instances : System.Web.UI.TemplateInstance
Public ReadOnly Property Instances As TemplateInstance

Valor de propiedad

Valor de enumeración de TemplateInstance que representa la instancia de la plantilla actual.A TemplateInstance enumeration value that the current template instance represents.

Ejemplos

En el ejemplo de código siguiente se muestra cómo Instances utilizar la propiedad.The following code example demonstrates how to use the Instances property. En el Page_Load caso de una página aspx, se MyLoginViewA consulta la clase TemplateInstanceAttribute del control personalizado AnonymousTemplate para la propiedad.In the Page_Load event of an ASPX page, the MyLoginViewA custom control's TemplateInstanceAttribute class for the AnonymousTemplate property is queried.

Para obtener la definición MyLoginViewA de control, TemplateInstanceAttributevea.For the definition of MyLoginViewA control, see TemplateInstanceAttribute.

protected void Page_Load(object sender, EventArgs e)
{
      
  // Get the class type for which to access metadata.
  Type clsType = typeof(MyLoginViewA);
  // Get the PropertyInfo object for FirstTemplate.
  PropertyInfo pInfo = clsType.GetProperty("AnonymousTemplate");
  // See if the TemplateInstanceAttribute is defined for this property.
  bool isDef = Attribute.IsDefined(pInfo, typeof(TemplateInstanceAttribute));

  // Display the result if the attribute exists.
  if (isDef)
  {
    TemplateInstanceAttribute tia =
      (TemplateInstanceAttribute)Attribute.GetCustomAttribute(pInfo, typeof(TemplateInstanceAttribute));
    Response.Write("The <AnonymousTemplate> has the TemplateInstanceAttribute = " + tia.Instances.ToString() + ".<br />");
    if (tia.IsDefaultAttribute())
      Response.Write("The TemplateInstanceAttribute used is the same as the default instance.");
    else
      Response.Write("The TemplateInstanceAttribute used is not the same as the default instance.");
  }

}
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
  
  ' Get the class type for which to access metadata.
  Dim clsType As Type = GetType(MyLoginViewA)
  ' Get the PropertyInfo object for FirstTemplate.
  Dim pInfo As PropertyInfo = clsType.GetProperty("AnonymousTemplate")
  ' See if the TemplateInstanceAttribute is defined for this property.
  Dim isDef As Boolean = Attribute.IsDefined(pInfo, GetType(TemplateContainerAttribute))
  
  ' Display the result if the attribute exists.
  If isDef Then
    Dim tia As TemplateInstanceAttribute = CType(Attribute.GetCustomAttribute(pInfo, GetType(TemplateInstanceAttribute)), TemplateInstanceAttribute)
    Response.Write("The <AnonymousTemplate> has the TemplateInstanceAttribute = " & tia.Instances.ToString() & ".<br />")
    If (tia.IsDefaultAttribute()) Then
      Response.Write("The TemplateInstanceAttribute used is the same as the default instance.")
    Else
      Response.Write("The TemplateInstanceAttribute used is not the same as the default instance.")
    End If

  End If

End Sub

Comentarios

Los valores posibles son el Single campo o el Multiple campo.The possible values are either the Single field or the Multiple field.

Se aplica a

Consulte también: