Пример #1
0
        /// <summary>
        /// Indicates whether the specified binder must bind this attribute of a control on postback.
        /// </summary>
        /// <param name="binder">The binder.</param>
        /// <returns>True if the binder must bind this attribute of a control on postback, false
        /// otherwise. The default value is false</returns>
        public static bool MustBindOnPostback(IControlBinder binder)
        {
            if (binder == null) return false;

            return (binder.GetType().GetCustomAttributes(typeof(BindOnPostbackAttribute), false).Length > 0);
        }
Пример #2
0
        /// <summary>
        /// Adds the specified control binder to its collection of control binders.
        /// </summary>
        /// <param name="controlBinder">The control binder to add.</param>
        private void AddBinder(IControlBinder controlBinder)
        {
            if (controlBinder != null)
            {
                foreach (string type in controlBinder.Types)
                {
                    _binders[type] = (_binders.ContainsKey(type)) ? _binders[type] : new List<IControlBinder>();

                    _binders[type].Add(controlBinder);
                }

                if (BindOnPostbackAttribute.MustBindOnPostback(controlBinder))
                {
                    foreach (string type in controlBinder.Types)
                    {
                        _postbackBinders[type] = (_postbackBinders.ContainsKey(type)) ? _postbackBinders[type] : new List<IControlBinder>();

                        _postbackBinders[type].Add(controlBinder);
                    }
                }
            }
        }