Exportar (0) Imprimir
Expandir Tudo
Este artigo foi traduzido por máquina. Coloque o ponteiro do mouse sobre as frases do artigo para ver o texto original. Mais informações.
Tradução
Original

TemplateControl Classe

Provides the Page class and the UserControl class with a base set of functionality.

Namespace:  System.Web.UI
Assembly:  System.Web (em System.Web. dll)

[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public abstract class TemplateControl : Control, INamingContainer, 
	IFilterResolutionService

The TemplateControl class is an abstract class that provides common properties and methods for the Page class and the UserControl class.A new instance of the TemplateControl is not created directly.

The TemplateControl class defines methods supporting declarative data-binding expressions:

  • Use the Eval method for data-binding expression involving data sources, such as simple properties or expressions.

  • Use the XPath method for parsing and evaluating an XPath data-binding expression.

  • Use the XPathSelect method for data-binding against an expression containing an XPath select statement.The result is a node collection that implements the IEnumerable interface.

For more information on data-binding expression, see Sintaxe de Expressãosões de ligação de dados and Ligando a bancos de dados.

The following code example demonstrates how to derive a control named MyControl from the TemplateControl class and override the Construct method.When MyControl is initialized, the overridden Construct method is called.

 System;
 System.Web;
 System.Web.UI;
 System.Web.UI.WebControls;
 System.Security.Permissions;


[AspNetHostingPermission(SecurityAction.Demand,
   Level = AspNetHostingPermissionLevel.Minimal)]
  MyControl : UserControl
{
    
     string _message = ;

     string Message
    {
         {  _message; }
         { _message = value; }
    }

    
      System.EventHandler myControl;

    
       Construct()
    {
        
        .myControl +=  EventHandler(MyInit);
    }

       OnInit(EventArgs e)
    {
        myControl(, e);
        Response.Write();
    }

    
     MyInit(object sender, System.EventArgs e)
    {
        Message = ;
    }

    
       Render(HtmlTextWriter writer)
    {
        writer.Write( + Message);
    }
}


Quaisquer membros públicos estático (compartilhados na Visual Basic) desse tipo são Thread seguro. Não há garantia de que qualquer membro de instância seja isento de segmentos.

Contribuições da comunidade

ADICIONAR
Mostrar:
© 2014 Microsoft