WebPartZone.GetInitialWebParts Método
Definição
protected public:
override System::Web::UI::WebControls::WebParts::WebPartCollection ^ GetInitialWebParts();
protected internal override System.Web.UI.WebControls.WebParts.WebPartCollection GetInitialWebParts ();
override this.GetInitialWebParts : unit -> System.Web.UI.WebControls.WebParts.WebPartCollection
Protected Friend Overrides Function GetInitialWebParts () As WebPartCollection
Retornos
Um WebPartCollection que contém todos os WebPart ou outros controles do servidor contidos no modelo da zona.A WebPartCollection that contains all the WebPart or other server controls contained in the zone's template.
Comentários
O GetInitialWebParts método fornece uma implementação do método base abstract GetInitialWebParts .The GetInitialWebParts method provides an implementation of the abstract base GetInitialWebParts method. O método base não fornece implementação, mas declara o método para que as classes derivadas possam personalizar como eles obterão o conjunto inicial de controles que pertencem a uma zona, sem fazer alterações de personalização em conta.The base method provides no implementation, but declares the method so that derived classes can customize how they will get the initial set of controls that belong in a zone, without taking personalization changes into account.
Para cada controle de servidor encontrado na zona, o CreateWebPart método é chamado.For each server control found in the zone, the CreateWebPart method is called. Se um controle herdar diretamente da WebPart classe, ele será simplesmente adicionado à coleção da zona WebParts (e à coleção semelhante do WebPartManager controle).If a control inherits directly from the WebPart class, it is simply added to the zone's WebParts collection (and to the similar collection of the WebPartManager control). Se um controle não herdar diretamente do WebPart , o conjunto de controle Web Parts encapsula o controle com um GenericWebPart objeto, o que permite que o controle se comporte como um WebPart controle em tempo de execução.If a control does not inherit directly from WebPart, the Web Parts control set wraps the control with a GenericWebPart object, which enables the control to behave as a WebPart control at run time.
A WebPartZone classe implementa o método base retornando o conjunto de controles (se houver) que são estaticamente declarados dentro de um conjunto de <zonetemplate> marcas na marcação de uma página de Web Parts.The WebPartZone class implements the base method by returning the set of controls (if any) that are statically declared within a set of <zonetemplate> tags in the markup of a Web Parts page. Se um PlaceHolder controle for declarado em uma zona, os controles filho desse controle serão adicionados, em vez do próprio controle.If a PlaceHolder control is declared in a zone, the child controls of that control are added, rather than the control itself. Essa implementação permite, por exemplo, criar uma WebPartZone zona em uma página mestra e, em seguida, declarar WebPart controles individuais ou de servidor em uma página de conteúdo.This implementation allows you to, for example, create a WebPartZone zone in a master page, and then declare individual WebPart or server controls in a content page. Se você declarar Literal controles em uma WebPartZone zona, eles serão ignorados.If you declare Literal controls in a WebPartZone zone, they are ignored.
Observação
A coleção inicial de controles retornados pelo GetInitialWebParts método pode ser diferente da coleção de tempo de execução real de controles em uma zona, após o efeito da personalização.The initial collection of controls returned by the GetInitialWebParts method might be different from the actual run-time collection of controls in a zone, after personalization has taken place. Por exemplo, suponha que você tenha uma página da Web com dois WebPartZone controles e que o primeiro contenha um controle de usuário chamado User1 que seja declarado estaticamente dentro das <zonetemplate> marcas.For example, suppose you have a Web page with two WebPartZone controls, and the first one contains user control named User1 that is statically declared within the <zonetemplate> tags. Se um usuário carregar a página e arrastar User1 para a segunda zona, User1 ainda será parte da coleção que é retornada chamando o GetInitialWebParts método da primeira zona, pois ela é declarada nessa zona.If a user loads the page and drags User1 into the second zone, then User1 is still part of the collection that is returned by calling the GetInitialWebParts method for the first zone, because it is declared in that zone. Mas, em tempo de execução, quando o WebPartManager controle carrega os dados de personalização, na User1 verdade aparece na segunda zona em que o usuário o arrastou.But at run time, when the WebPartManager control loads the personalization data, User1 actually appears in the second zone where the user dragged it.