I'm working on a custom control that needs to register client script to the
page.
string key = "ScriptKey";
string script = "<script language=\"javascript\"> alert('Hi'); </script>";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), key, script,
false);
The code executes, but no script is rendered to the page. Is there
something I'm missing here?
I've tried moving this around even, including RenderControl(), OnLoad(),
OnPreRender(), and OnInit().
Thanks!
Sebastian - 19 Apr 2006 10:15 GMT
Hi Rory,
try:
if (!this.IsClientScriptBlockRegistered("clientScript"))
{
your script made with StringBuilder
this.RegisterClientScriptBlock("clientScript",
yourStringBuilder.ToString());
}
It works on my page. Hope it helps.
> I'm working on a custom control that needs to register client script to the
> page.
[quoted text clipped - 11 lines]
>
> Thanks!