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

J

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
(e-mail address removed)
 
P

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top