Where to Call RegisterArrayDeclaration in Composite Server Control?

K

Ken Baltrinic

I am authoring a composite server control (inheriting from
System.Web.UI.Control) that uses a good chunk of client side javascript. To
make this work I need to call RegisterArrayDeclaration and in a manner
simmilar to the following:

Page.RegisterArrayDeclaration(
dataObjectArrayName,
string.Format(
"{{ spanID:'{0}', calendarID:'{1}' }}",
spanID,
calendarID));

Where SpanID and CalendarID are the ClientID values of two controls added
when overriding Control.CreateChildControls. Normally one would call
RegisterArrayDeclaration() in OnLoad, but this occurrs before
CreateChildControls and the ClientID values would not be available at that
point. (I am presuming that the ClientID becomes available once the span
and calendar controls are added to my composite control's controls
collection, correct?). So my question is where can I call
RegisterArrayDeclaration? Can I call it any time prior to rendering (such
as in OnPreRender?).

I also need to call RegisterStartupScript and RegisterClientScriptBlock as
well, though these I can still call in OnLoad since they do not need the
ClientID values of the child controls. Yet I am currious as to whereelse I
may be able to safely call these methods as well.

--Ken
 

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
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top