Beispiel #1
0
        internal override void AddAttributes()
        {
            base.AddAttributes();
            var innerAttr = new Dictionary <string, string>();

            if (DateTimeFormat.IsNullOrEmpty())
            {
                DateTimeFormat = "yyyy-MM-dd";
            }
            if (!Value.IsNullOrEmpty())
            {
                DateTime dt;
                if (DateTime.TryParse(Value, out dt))
                {
                    Value = dt.ToString(DateTimeFormat);
                }
            }
            innerAttr.Add("dateFmt", StringProperty(DateTimeFormat));
            if (ChangeTiggerSearch)
            {
                innerAttr.Add("onpicked", "function(){$(this).closest('[searchForm]').submit();}");
            }
            else
            {
                if (!OnDatePicked.IsNullOrEmpty())
                {
                    innerAttr.Add("onpicked", OnDatePicked);
                }
            }
            if (!Maximum.IsNullOrEmpty())
            {
                innerAttr.Add("maxDate", StringProperty(Maximum));
            }
            if (!String.IsNullOrEmpty(Minimum))
            {
                innerAttr.Add("minDate", StringProperty(Minimum));
            }
            if (GreaterThanToday)
            {
                innerAttr.Add("minDate", StringProperty(DateTime.Now.ToString()));
            }
            if (!string.IsNullOrEmpty(MinDateControl))
            {
                innerAttr.Add("minDate", "\'#F{$dp.$D(\\\'" + MinDateControl + "\\\');}\'");
            }
            if (!string.IsNullOrEmpty(MaxDateControl))
            {
                innerAttr.Add("maxDate", "\'#F{$dp.$D(\\\'" + MaxDateControl + "\\\');}\'");
            }
            if (ShowWeek)
            {
                innerAttr.Add("isShowWeek", "true");
            }
            StringBuilder innerAttrStr = new StringBuilder();

            innerAttr.ForEach((dict) =>
            {
                innerAttrStr.AppendFormat(",{0}:{1}", dict.Key, dict.Value);
            });
            Attributes["onclick"] = "WdatePicker({{{0}}});".FormatTo(innerAttrStr.ToString().Substring(1));
            Attributes["value"]   = Value;
        }