protected override void OnInit(EventArgs e)
 {
     // Hook up an AjaxMethodCallback control for the autocomplete handler
     this.Page.PreLoad += (obj, ev) =>
     {
         AjaxMethodCallback = AjaxMethodCallback.CreateControlInstanceOnPage(this);
         AjaxMethodCallback.PageProcessingMode = CallbackProcessingModes.PageLoad;
     };
 }
        /// <summary>
        /// Can be called to create a new instance of the AjaxMethodCallbackControl
        /// and attach it to the current page. This can be useful for control developers
        /// so they don't have to manually add the control to the page.
        ///
        /// The call to this method should be made pre-OnLoad() preferrably in OnInit().
        /// </summary>
        /// <param name="page">Instance of the Page object</param>
        /// <returns>An instance of the Callback Control</returns>
        public static AjaxMethodCallback CreateControlInstanceOnPage(Control control, object targetInstance = null)
        {
            AjaxMethodCallback callback = new AjaxMethodCallback();

            callback.Page = control.Page;
            callback.ID   = control.ID + "_Callback";

            if (targetInstance != null)
            {
                callback.TargetInstance = targetInstance;
            }
            else
            {
                callback.TargetInstance = control;
            }

            control.Controls.Add(callback);
            return(callback);
        }
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            // Make sure we use block mode instead of stock inline-block
            this.Style.Add(HtmlTextWriterStyle.Display, "block");

            this.Style.Add(HtmlTextWriterStyle.Margin, "10px");
            this.Controls.Add(new LiteralControl(string.Format("<b>{0}</b><hr/>", Resources.Resources.LocalizationOptions)));

            Image img = new Image();

            if (this.Page != null)
                img.ImageUrl = this.Page.ClientScript.GetWebResourceUrl(this.GetType(), GlobalizationResources.INFO_ICON_EDITRESOURCES);

            img.Style[HtmlTextWriterStyle.MarginRight] = "10px";
            this.Controls.Add(img);

            // Add an Ajax Callback control to handle inline display
            AjaxMethodCallback callback = new AjaxMethodCallback();
            callback.PageProcessingMode = CallbackProcessingModes.PageLoad;
            callback.TargetInstance = this;
            callback.ID = "_resourceCallback";
            callback.ClientProxyTargetType = this.GetType();
            callback.GenerateClientProxyClass = ProxyClassGenerationModes.Inline;
            this.Controls.Add(callback);



            LinkButton button = this.btnEditResources;
            button.ID = "btnEditResources";
            button.Text = Resources.Resources.EditPageResources;
            //but.Attributes.Add("target", "LocalizationForm");
            button.Click += new EventHandler(OnEditResources);
            this.Controls.Add(button);

            this.Controls.Add(new LiteralControl("<br/>"));

            CheckBox cb = this.chkShowIcons;
            cb.ID = "chkShowIcons";
            cb.Text = Resources.Resources.ShowLocalizationIcons;
            cb.AutoPostBack = true;
            cb.Checked = this.ShowIcons;
            cb.CheckedChanged += new EventHandler(this.OnShowIcons);

            this.Controls.Add(cb);
        }
        /// <summary>
        /// Can be called to create a new instance of the AjaxMethodCallbackControl
        /// and attach it to the current page. This can be useful for control developers
        /// so they don't have to manually add the control to the page.
        /// 
        /// The call to this method should be made pre-OnLoad() preferrably in OnInit().
        /// </summary>
        /// <param name="page">Instance of the Page object</param>
        /// <returns>An instance of the Callback Control</returns>
        public static AjaxMethodCallback CreateControlInstanceOnPage(Control control, object targetInstance = null)
        {
            AjaxMethodCallback callback = new AjaxMethodCallback();
            callback.Page = control.Page;
            callback.ID = control.ID + "_Callback";

            if (targetInstance != null)
                callback.TargetInstance = targetInstance;
            else
                callback.TargetInstance = control;             
            
            control.Controls.Add(callback);
            return callback;            
        }
 protected override void OnInit(EventArgs e)
 {
     // Hook up an AjaxMethodCallback control for the autocomplete handler
     this.Page.PreLoad += (obj, ev) =>
     {
         AjaxMethodCallback = AjaxMethodCallback.CreateControlInstanceOnPage(this);
         AjaxMethodCallback.PageProcessingMode = CallbackProcessingModes.PageLoad;
     };
 }