R
RAJ
In our multi-tier application, we have several ASP.NET user controls which
will update the same data source provided by middle tier logic.
In this particular scenario we have one user control displaying the contents
of the data source, whilst another control updates the datasource via a
command buttons implementation of 'Click', an event raised in the 'Handle
Postback Events' stage of the control execution life cycle (via the
RaisePostBackEvent method).
These user controls are structured at present, in the Page_Load event,
including the control which is concerned only with displaying the datasource
contents. The problem therefore is that if the control has already been
structured for rendering, and the datasource is updated afterwards, then the
changes to the datasource are not present in the displaying control, but are
present in the updating control.
Now seeing as though the command button constituent controls (which
implement the IPostBackDataHandler marker interface) are instantiated
straight from Page_Init (regardless to their presence in the designer or
created manually for composition), then even if the rest of the control
isn't structured in Page_Load, during the 'Handle Postback Events' stage of
the control execution life cycle, this control would still perform its
'Click' event?
Please also consider the following factors:
.. Either control is capable of updating the data source (so one may be the
updater, the other the displayer, and vice versa)
.. The 'Load' phase of the controls execution life cycle states: 'At this
point, server controls in the tree are created and initialized, the state is
restored, and form controls reflect client-side data.'.
.. The controls execution life cycle also states: 'The CreateChildControls
method is not listed in the table because it is called whenever the ASP.NET
page framework needs to create the controls tree and this method call is not
limited to a specific phase in a control's lifecycle. For example,
CreateChildControls can be invoked when loading a page, during data binding
or during rendering.'.
Is it therefore possible to 'EnsureChildControls' from the 'Click' event of
the updating controls command button, create the input controls which had
taken part in the post-back process, obtain the postback data from these
input controls (Note that at this point, the 'Load' phase has already run!
Have these controls missed out their viewstate and postback processing
stage?!?) and update the datasource?
Likewise if this control is not updating the datasource, is it safe to
assume that it would be possible to render the displaying control in
CreateChildControls, which is ensured (EnsureChildControls) from the
PreRender event?
This would remove the requirement for either a Server.Transfer or
Response.Redirect from the command buttons 'Click' event, of which the
former is difficult to cater for (because it retains the original
HTTPRequest, disabling different user controls ability to structure URLs
correctly), and the latter which causes an additional round trip to client
and server.
Any insight into this perplexing problem would be greatly appreciated!
Thanks
RAJ
will update the same data source provided by middle tier logic.
In this particular scenario we have one user control displaying the contents
of the data source, whilst another control updates the datasource via a
command buttons implementation of 'Click', an event raised in the 'Handle
Postback Events' stage of the control execution life cycle (via the
RaisePostBackEvent method).
These user controls are structured at present, in the Page_Load event,
including the control which is concerned only with displaying the datasource
contents. The problem therefore is that if the control has already been
structured for rendering, and the datasource is updated afterwards, then the
changes to the datasource are not present in the displaying control, but are
present in the updating control.
Now seeing as though the command button constituent controls (which
implement the IPostBackDataHandler marker interface) are instantiated
straight from Page_Init (regardless to their presence in the designer or
created manually for composition), then even if the rest of the control
isn't structured in Page_Load, during the 'Handle Postback Events' stage of
the control execution life cycle, this control would still perform its
'Click' event?
Please also consider the following factors:
.. Either control is capable of updating the data source (so one may be the
updater, the other the displayer, and vice versa)
.. The 'Load' phase of the controls execution life cycle states: 'At this
point, server controls in the tree are created and initialized, the state is
restored, and form controls reflect client-side data.'.
.. The controls execution life cycle also states: 'The CreateChildControls
method is not listed in the table because it is called whenever the ASP.NET
page framework needs to create the controls tree and this method call is not
limited to a specific phase in a control's lifecycle. For example,
CreateChildControls can be invoked when loading a page, during data binding
or during rendering.'.
Is it therefore possible to 'EnsureChildControls' from the 'Click' event of
the updating controls command button, create the input controls which had
taken part in the post-back process, obtain the postback data from these
input controls (Note that at this point, the 'Load' phase has already run!
Have these controls missed out their viewstate and postback processing
stage?!?) and update the datasource?
Likewise if this control is not updating the datasource, is it safe to
assume that it would be possible to render the displaying control in
CreateChildControls, which is ensured (EnsureChildControls) from the
PreRender event?
This would remove the requirement for either a Server.Transfer or
Response.Redirect from the command buttons 'Click' event, of which the
former is difficult to cater for (because it retains the original
HTTPRequest, disabling different user controls ability to structure URLs
correctly), and the latter which causes an additional round trip to client
and server.
Any insight into this perplexing problem would be greatly appreciated!
Thanks
RAJ