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
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