What I m trying to do is call a Java Applet method immediately after PostBack of an ASP.NET page. In order to accomplish this I m using the ScriptManager.RegisterStartupScript function which I pass a small script block to call a function in the page that then calls the Applet function. It seems multi-step but I get nothing if I just try to call the Applet function from my script block written in the code behind. I ve actually achieved the result I m after but only when I first put a JavaScript alert in the function being called by the code behind script block.
The question is does anyone know how I can get around having to fire an alert prior to the Applet function being called?
Here s some simplified pseudo-code to better describe the scenario.
(.ascx.cs - yes this is in a user control, perhaps that is problematic?) protected void SetupAppletInput() { string scriptBlock = CreateJavaScriptBlock(dataForApplet); ScriptManager.RegisterStartupScript(grvDataSet, grvDataSet.GetType(), "clicky", scriptBlock, true); } protected string CreateJavaScriptBlock(String dataForApplet) { StringBuilder sb = new StringBuilder(); sb.Append("CallAppletFunction(dataForApplet);"); return sb.ToString(); } (.ascx) function CallAppletFunction(dataForApplet) { alert("Calling applet function"); // with this line in it works, but is really annoying to have to click the alert off for every PostBack document.ReallyCoolApplet.functionToCall(dataForApplet); }
Outside of this I believe the only relevant facts to be that the portion of the page being posted back is in an UpdatePanel but the Applet itself is not in an update panel and I believe it isn t getting re-loaded.
Hopefully I explained this adequately. Thanks for any help/thoughts on this!