By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,759 Members | 959 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,759 IT Pros & Developers. It's quick & easy.

Where to Call RegisterArrayDeclaration in Composite Server Control?

P: n/a
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
Nov 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.