I currently have a page that dynamically loads a user control when a button click is executed. The user control is placed on the page and loaded within a radajaxpanel. I need to run a javascript function at the completion of the user control being loaded that accesses controls within that user control. I have tried a few different ways to get this to happen, but I am unable to get it to work.
What does work is when I remove the radajaxpanel and then at the bottom of the ascx page I include the javascript function that I want to run followed by window.onload = functionToRun, but then I get the page reload etc.
I have tried to register the script at prerender, and also tried the following in the Page_PreRender of the user control to run the desired function:
System.Web.UI.
Page page = (System.Web.UI.Page)this.Page;
MasterPage mp1 = (MasterPage)page.Master;
RadAjaxManager ajm = mp1.FindControl("RadAjaxManager1") as RadAjaxManager;
string script = String.Format("functionToRun();");
ajm.ResponseScripts.Add(script);
It finds the objects it needs within the codebehind, but then cannot find the functionToRun when it is time to run the client side function.
Is there a post or article that describes the best way to run a client side function once a dynamically loaded user control has finished loading within a RadAjaxPanel?
Thank you,
Aaron