Beispiel #1
0
 public AjaxEventTriplet(string name, ComponentAjaxEvent ajaxEvent, ClientConfigAttribute attribute, PropertyInfo propertyInfo)
 {
     this.name         = name;
     this.ajaxEvent    = ajaxEvent;
     this.attribute    = attribute;
     this.propertyInfo = propertyInfo;
 }
Beispiel #2
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);
        }
Beispiel #3
0
        public override void WriteJson(JsonWriter writer, object value)
        {
            if (value != null && value is ComponentAjaxEvent)
            {
                ComponentAjaxEvent ajaxEvent = (ComponentAjaxEvent)value;

                writer.WriteRawValue(new ClientConfig().Serialize(ajaxEvent));
                return;
            }
            writer.WriteRawValue("{}");
        }
Beispiel #4
0
        void Owner_Load(object sender, EventArgs e)
        {
            WebControl owner = (WebControl)sender;

            foreach (AjaxEventTriplet ajaxEvent in this.AjaxEvents)
            {
                ComponentAjaxEvent ae = ajaxEvent.AjaxEvent;
                ae.Owner             = owner;
                ae.ExtraParams.Owner = owner;
                foreach (Parameter param in ae.ExtraParams)
                {
                    param.Owner = owner;
                }
            }
        }
Beispiel #5
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;
                    }
                }
            }
        }
Beispiel #6
0
        public override void LoadViewState(object state)
        {
            object[] states = state as object[];

            if (states != null)
            {
                foreach (Pair pair in states)
                {
                    string ajaxEventName  = (string)pair.First;
                    object ajaxEventState = pair.Second;

                    if (ajaxEventName == "base")
                    {
                        base.LoadViewState(ajaxEventState);
                    }
                    else
                    {
                        PropertyInfo property = this.GetType().GetProperty(ajaxEventName);

                        if (property == null)
                        {
                            throw new InvalidOperationException(string.Format("Can't find the property '{0}'", ajaxEventName));
                        }

                        ComponentAjaxEvent componentAjaxEvent = (ComponentAjaxEvent)property.GetValue(this, null);
                        if (componentAjaxEvent != null)
                        {
                            componentAjaxEvent.LoadViewState(ajaxEventState);
                        }
                    }
                }
            }
            else
            {
                base.LoadViewState(state);
            }
        }