Home All Groups Group Topic Archive Search About

I want to do a process once per page process, but 'touch' all instances of my server control.

Author
1 Jun 2005 6:56 PM
Jason Kendall
I have a server control that emits some client side script.  Rather
than have a script block for every instance of my server control, I'd
like to have one block that contains the code for all of instances.

I have looked into the OnInit, OnLoad and OnPreRender events, but the
"MyBase.Page.Controls" collection never seems to contain my controls.

Any tips would be appreciated.


-Jason Kendall
JasonKend***@hotmail.com

Author
1 Jun 2005 7:06 PM
Patrice
Looks you have two different issues ?

Try IsClientScriptRegistered/RegisterClientScriptBlock. It allows to avoid
rendering the script if it has already been rendered previously...

For the second point you'll likely have to elaborate a bit...How do you look
at Page.Controls (your controls might be itself inside an inner control ?).
What if you start by looking at the HTML ? Do you see what your control is
supposed to render ? If should be a fairly good indication of wether or not
your control is actually in the control hierarchy...

Patrice


--

Show quoteHide quote
"Jason Kendall" <JasonKend***@hotmail.com> a écrit dans le message de
news:u11s91h0b0hcv1kiot2ona9j4m48jga76f@4ax.com...
> I have a server control that emits some client side script.  Rather
> than have a script block for every instance of my server control, I'd
> like to have one block that contains the code for all of instances.
>
> I have looked into the OnInit, OnLoad and OnPreRender events, but the
> "MyBase.Page.Controls" collection never seems to contain my controls.
>
> Any tips would be appreciated.
>
>
> -Jason Kendall
> JasonKend***@hotmail.com