Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Manipulate style/classes after all controls are being created - how? (http://www.velocityreviews.com/forums/t586216-manipulate-style-classes-after-all-controls-are-being-created-how.html)

DC 01-21-2008 05:51 PM

Manipulate style/classes after all controls are being created - how?
 
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

DC 01-31-2008 11:42 AM

Re: Manipulate style/classes after all controls are being created -how?
 
On 21 Jan., 18:51, DC <d...@upsize.de> 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

DC 01-31-2008 01:24 PM

Re: Manipulate style/classes after all controls are being created -how?
 
On 31 Jan., 12:42, DC <d...@upsize.de> wrote:
> On 21 Jan., 18:51,DC<d...@upsize.de> 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
>
> }
>
> CheersDC- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -


Thank you! Just what I was looking for.

Regards
DC


All times are GMT. The time now is 03:52 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.