PreRender Question...
-
In WebCustomControl the pre-render is executed before rendering:-) - We all know that. BUT - i noticed that this expected behavior doesn't match the design time. That is, in run time the rendering process is somthing like: ....-->OnPreRender-->PreRender(Event)-->Render-->... while in design time is: ....???-->Render-->... I would like to add some code to be executed JUST BEFORE rendering and that should be run ALSO in design time. Thanks in advanced, Ilan
-
In WebCustomControl the pre-render is executed before rendering:-) - We all know that. BUT - i noticed that this expected behavior doesn't match the design time. That is, in run time the rendering process is somthing like: ....-->OnPreRender-->PreRender(Event)-->Render-->... while in design time is: ....???-->Render-->... I would like to add some code to be executed JUST BEFORE rendering and that should be run ALSO in design time. Thanks in advanced, Ilan
e-laj wrote:
That is, in run time the rendering process is somthing like: ....-->OnPreRender-->PreRender(Event)-->Render-->... while in design time is: ....???-->Render-->...
The life cycle of the control at run time should be taking place in the way that you already know. However, thing is a bit different at design time since each control has a control designer that is responsible for controlling the appearance of the control at design time. In details, the
GetDesignTimeHtml
method of the designer will invoke theRender
method of the control to create the appearance for the control in the design view. So your sample code in the PreRender event handler only runs at run time, and it does not get executed by the designer. For more information, you can see: Implementing a Simple Web Forms Control Designer[^]e-laj wrote:
I would like to add some code to be executed JUST BEFORE rendering and that should be run ALSO in design time
There are two options IMO that you might consider: + In the custom control, you override the
Render
method, and execute your sample code in there. + Implement a custom control designer for your custom control, and you can ovveride theGetDesignTimeHtml
method to execute your sample code at design time only.