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); }
/// <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; }