Pergunta

While writing code for connecting two webparts, i noticed that when i try to retrieve the data from Provider WebPart in CreateChildControl method, the connection object is shown as NULL. However, when i write the code in PreRender method , everything is working fine. Is there any specific reason to write the retrieval code in PreRender method only??

Foi útil?

Solução

Introducing ASP.NET Web Part Connections

(...) the ASP.NET team recommends that consumer Web Parts should not use methods or properties on the provider interface until the PreRender phase. Specifically, they should not use methods or properties on the provider interface in the method itself. The reason is that connections may have dependencies on each other. You may have a ProviderWebPart, connected to a ProviderConsumerWebPart, connected to a ConsumerWebPart. The ConsumerWebPart cannot query the provider interface until both connections have been established, and the order in which the connections are established is up to the Framework.

SharePoint Web Part Event Flow in detail

SharePoint Web Part - Event Flow chart

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top