At first glance, it should be easy to inject a javascript, but it took a little bit of digging around to figure out the resolution, the key is to use ScriptManager.
<asp:UpdatePanel ID="myUpdatePanel" UpdateMode="Conditional" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnClick" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:ImageButton ID="btnClick" ImageUrl="ClickMe.png" runat="server"
CausesValidation="false" OnClick="btnClickEvent" ToolTip="Click Me"
AlternateText="Click me!" />
</ContentTemplate>
</asp:UpdatePanel>
We wanted to dynamically inject some JavaScript code. If my ScriptManager control has EnablePartialRendering set to true, it's a simple matter of registering the script. What i didn't realize earlier was that you don't need to the use the current page or current event, you need to call the static method on the ScriptManager class.
protected void btnClickEvent(object sender, ImageClickEventArgs e)
{
btnClick.Text = "I was clicked."
btnClick.Disabled = true;
ScriptManager.RegisterClientScriptBlock(myUpdatePanel,
typeof(UpdatePanel),myUpdatePanel.ClientID,
"alert('It worked!');",true);
}
That's it! Use the ScriptManager class, point it to the instance of your update panel, pass it a unique key and then the JavaScript you want, and it will be executed once the update panel is done rendering.