Manipulate style/classes after all controls are being created - how?

Manipulate style/classes after all controls are being created - how?

am 21.01.2008 18:51:13 von DC

Hi,

I am writing a "print control" routine which expects the id of a
control and will then make every element but the one that is supposed
to be printed invisible (only by using "display: none" style;
Visible=false causes a lot of collateral damage in my scenario).

I thought if I put this into "OnPreRender" I will catch all controls
in the state they will have in the page render method, but if there
are e.g. databound controls that are being setup in the
control_prerender method (for good reason, actually) then the
"display: none" style information may be overwritten by that method
since the page OnPreRender executes before the control's PreRender.

Is there a good time to manipulate the control tree knowing that the
alterations being made are the last ones before rendering, or a
different approach to my aim?

TIA for any hints!
Regards
DC

Re: Manipulate style/classes after all controls are being created -

am 31.01.2008 12:42:36 von DC

On 21 Jan., 18:51, DC wrote:
> Hi,
>
> I am writing a "print control" routine which expects the id of a
> control and will then make every element but the one that is supposed
> to be printed invisible (only by using "display: none" style;
> Visible=false causes a lot of collateral damage in my scenario).
>
> I thought if I put this into "OnPreRender" I will catch all controls
> in the state they will have in the page render method, but if there
> are e.g. databound controls that are being setup in the
> control_prerender method (for good reason, actually) then the
> "display: none" style information may be overwritten by that method
> since the page OnPreRender executes before the control's PreRender.
>
> Is there a good time to manipulate the control tree knowing that the
> alterations being made are the last ones before rendering, or a
> different approach to my aim?
>
> TIA for any hints!
> Regards
> DC

You can hook to a number of events to accomplish this, one possiblity
is:

protected override void OnInit(EventArgs e)
{
Page.PreRenderComplete += new EventHandler(Page_PreRenderComplete);
}

void Page_PreRenderComplete(object sender, EventArgs e)
{
// do the style thing
}

Cheers
DC

Re: Manipulate style/classes after all controls are being created -

am 31.01.2008 14:24:18 von DC

On 31 Jan., 12:42, DC wrote:
> On 21 Jan., 18:51,DC wrote:
>
>
>
>
>
> > Hi,
>
> > I am writing a "print control" routine which expects the id of a
> > control and will then make every element but the one that is supposed
> > to be printed invisible (only by using "display: none" style;
> > Visible=3Dfalse causes a lot of collateral damage in my scenario).
>
> > I thought if I put this into "OnPreRender" I will catch all controls
> > in the state they will have in the page render method, but if there
> > are e.g. databound controls that are being setup in the
> > control_prerender method (for good reason, actually) then the
> > "display: none" style information may be overwritten by that method
> > since the page OnPreRender executes before the control's PreRender.
>
> > Is there a good time to manipulate the control tree knowing that the
> > alterations being made are the last ones before rendering, or a
> > different approach to my aim?
>
> > TIA for any hints!
> > Regards
> >DC
>
> You can hook to a number of events to accomplish this, one possiblity
> is:
>
> protected override void OnInit(EventArgs e)
> {
> =A0 =A0Page.PreRenderComplete +=3D new EventHandler(Page_PreRenderComplete=
);
>
> }
>
> void Page_PreRenderComplete(object sender, EventArgs e)
> {
> =A0 =A0// do the style thing
>
> }
>
> CheersDC- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

Thank you! Just what I was looking for.

Regards
DC