Esempio n. 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);
        }
Esempio n. 2
0
        private void InitEventsOwner()
        {
            PropertyInfo componentListeners = this.GetType().GetProperty(Observable.ListenersKey);

            if (componentListeners != null)
            {
                ComponentListeners     listeners  = componentListeners.GetValue(this, null) as ComponentListeners;
                List <ListenerTriplet> properties = listeners.Listeners;

                foreach (ListenerTriplet property in properties)
                {
                    ComponentListener listener = property.Listener;
                    if (listener != null)
                    {
                        listener.Owner = this;
                    }
                }
            }

            PropertyInfo ajaxEvents = this.GetType().GetProperty(Observable.AjaxEventsKey);

            if (ajaxEvents != null)
            {
                ComponentAjaxEvents     events     = ajaxEvents.GetValue(this, null) as ComponentAjaxEvents;
                List <AjaxEventTriplet> properties = events.AjaxEvents;

                foreach (AjaxEventTriplet property in properties)
                {
                    ComponentAjaxEvent ajaxEvent = property.AjaxEvent;
                    if (ajaxEvent != null)
                    {
                        ajaxEvent.Owner             = this;
                        ajaxEvent.ExtraParams.Owner = this;
                        foreach (Parameter param in ajaxEvent.ExtraParams)
                        {
                            param.Owner = this;
                        }
                    }

                    if (!ajaxEvent.IsDefault)
                    {
                        this.ForceIDRendering = true;
                    }
                }
            }
        }