Scope of JavaScript functions in server controls
===

I have decided to learn how to create server controls because of the problems I was having with user controls. I wanted to be able to create JavaScript functions for my user controls so I could call userControl1.clientSideFunction(); You cant actually do this with user controls because the function would just get put into the page as clientSideFunction(); and not actually be attached to the user control. There are ways to accomplish this with a user control but it's not designed to allow for it. From my understanding server controls were designed to allow for this. I can't find very much information about it, does anyone know how to do this? Here is the basic outline of my control.

    namespace ServerControl1
    {
        public class Class1 : CompositeControl
        {
            private DevExpress.Web.ASPxEditors.ASPxButton btnTest;
            private DevExpress.Web.ASPxPopupControl.ASPxPopupControl popupTest;

            protected override void Render(HtmlTextWriter writer)
            {
                writer.Write("<h1>This is my control</h1>");      
            }

            protected override void CreateChildControls()
            {
                btnTest = new DevExpress.Web.ASPxEditors.ASPxButton();
                btnTest.Text = "wazzzup"; 

                popupTest = new DevExpress.Web.ASPxPopupControl.ASPxPopupControl();
                popupTest.Width = Unit.Pixel(500);
                popupTest.Height = Unit.Pixel(500);
                popupTest.Controls.Add(btnTest);
                popupTest.ShowOnPageLoad = true;
                Controls.Add(popupTest);                       
            }
        }
    }