Example #1
0
        internal void FireAsyncEvent(string eventName, ParameterCollection extraParams)
        {
            ComponentAjaxEvents ajaxevents = this.GetAjaxEvents();

            if (ajaxevents == null)
            {
                throw new HttpException("The control has no AjaxEvents");
            }

            PropertyInfo eventListenerInfo = ajaxevents.GetType().GetProperty(eventName);

            if (eventListenerInfo.PropertyType != typeof(ComponentAjaxEvent))
            {
                throw new HttpException(string.Format("The control '{1}' does not have an AjaxEvent with the name '{0}'", eventName, this.ClientID));
            }

            ComponentAjaxEvent ajaxevent = eventListenerInfo.GetValue(ajaxevents, null) as ComponentAjaxEvent;

            if (ajaxevent == null || ajaxevent.IsDefault)
            {
                throw new HttpException(string.Format("The control '{1}' does not have an AjaxEvent with the name '{0}' or the handler is absent", eventName, this.ClientID));
            }
            AjaxEventArgs e = new AjaxEventArgs(extraParams);

            ajaxevent.OnEvent(e);
        }