J
JV
I'm aware of RegisterClientScriptBlock and RegisterStartupScript, but ....
Suppose you need to execute some script code when your page loads....perhaps
you need to call an Init() function and pass it a reference to your control.
Of course you can emit a client script for the OnLoad event of the page, but
there are problems with that:
(1) if there's already an OnLoad script on the page, then only the
last one will actually be executed (I tested this out in HTML with multiple
OnLoad scripts)
(2) if you have more than one instance of your control on a form, and
the Init() function needs to be called once for each control instance, now
you have to figure out how to APPEND script code to the OnLoad script.
Don't see any way to make that work.
And, of course, individual elements like <table> don't fire OnLoad so you
can't just hook those. Oh they fire some other event like that, but only
when they have a behavior assigned to them. Not too useful here.
I'm sure this has to be a common problem in developing custom web controls.
Has someone devised a means to do it?
Suppose you need to execute some script code when your page loads....perhaps
you need to call an Init() function and pass it a reference to your control.
Of course you can emit a client script for the OnLoad event of the page, but
there are problems with that:
(1) if there's already an OnLoad script on the page, then only the
last one will actually be executed (I tested this out in HTML with multiple
OnLoad scripts)
(2) if you have more than one instance of your control on a form, and
the Init() function needs to be called once for each control instance, now
you have to figure out how to APPEND script code to the OnLoad script.
Don't see any way to make that work.
And, of course, individual elements like <table> don't fire OnLoad so you
can't just hook those. Oh they fire some other event like that, but only
when they have a behavior assigned to them. Not too useful here.
I'm sure this has to be a common problem in developing custom web controls.
Has someone devised a means to do it?