🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: alt.pl.comp.lang.csharp
3 messages
3 total messages Started by 3P Sun, 10 Oct 2010 19:24
ASP.NET: Dynamiczne dodawanie kontrolek
#21781
Author: 3P
Date: Sun, 10 Oct 2010 19:24
6 lines
1027 bytes
Hej.

Gdzie powinienem dodawać dynamicznie kontrolki? W Page_Load, czy  
Page_PreInit.
Wydawało mi się, że w Page_PreInit, bo po nim zostaną odtworzone wartości  
tej kontrolki z ViewState, ale w Page_Load także to działa.
Re: ASP.NET: Dynamiczne dodawanie kontrolek
#21782
Author: Wiktor Zychla
Date: Mon, 11 Oct 2010 09:52
30 lines
2591 bytes
> Wydawało mi się, że w Page_PreInit, bo po nim zostaną odtworzone wartości 
> tej kontrolki z ViewState, ale w Page_Load także to działa.

viewstate jest ładowany rzeczywiście wcześniej, ale dotyczy to tylko 
kontrolek osadzonych statycznie.

dla kontrolek dynamicznych (również tych z szablonów) ich zdarzenia 
przesuwają się w czasie. przecież np. kontrolki z templateów gridów powstają 
dopiero przy bindowaniu szablonu, co standardowo dzieje się między PreRender 
a PreRenderComplete (czyli JESZCZE później niż Load), a przecież te 
kontrolki też muszą mieć możliwość "nadgonienia" potoku zdarzeń.

w dokumentacji jest nawet taka informacja:

http://msdn.microsoft.com/en-us/library/ms178472.aspx

Catch-Up Events for Added Controls

If controls are created dynamically at run time or declaratively within 
templates of data-bound controls, their events are initially not 
synchronized with those of other controls on the page. For example, for a 
control that is added at run time, the Init and Load events might occur much 
later in the page life cycle than the same events for controls created 
declaratively. Therefore, from the time that they are instantiated, 
dynamically added controls and controls in templates raise their events one 
after the other until they have caught up to the event during which it was 
added to the Controls collection.

pozdrawiam
Wiktor Zychla 
Re: ASP.NET: Dynamiczne dodawanie kontrolek
#21783
Author: 3P
Date: Mon, 11 Oct 2010 16:15
43 lines
2881 bytes
Dnia 11-10-2010 o 11:52:55 Wiktor Zychla <wzychla@nospam.com> napisał(a):

>> Wydawało mi się, że w Page_PreInit, bo po nim zostaną odtworzone  
>> wartości tej kontrolki z ViewState, ale w Page_Load także to działa.
>
> viewstate jest ładowany rzeczywiście wcześniej, ale dotyczy to tylko  
> kontrolek osadzonych statycznie.
>
> dla kontrolek dynamicznych (również tych z szablonów) ich zdarzenia  
> przesuwają się w czasie. przecież np. kontrolki z templateów gridów  
> powstają dopiero przy bindowaniu szablonu, co standardowo dzieje się  
> między PreRender a PreRenderComplete (czyli JESZCZE później niż Load), a  
> przecież te kontrolki też muszą mieć możliwość "nadgonienia" potoku  
> zdarzeń.
>
> w dokumentacji jest nawet taka informacja:
>
> http://msdn.microsoft.com/en-us/library/ms178472.aspx
>
> Catch-Up Events for Added Controls
>
> If controls are created dynamically at run time or declaratively within  
> templates of data-bound controls, their events are initially not  
> synchronized with those of other controls on the page. For example, for  
> a control that is added at run time, the Init and Load events might  
> occur much later in the page life cycle than the same events for  
> controls created declaratively. Therefore, from the time that they are  
> instantiated, dynamically added controls and controls in templates raise  
> their events one after the other until they have caught up to the event  
> during which it was added to the Controls collection.
>

Czytałem to wczoraj. Ale niżej jest napisane:

Life-Cycle Events
PreInit	
Raised after the start stage is complete and before the initialization  
stage begins.
Use this event for the following:
Check the IsPostBack property to determine whether this is the first time  
the page is being processed. The IsCallback and IsCrossPagePostBack  
properties have also been set at this time.
--> Create or re-create dynamic controls.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads