Ejemplo n.º 1
0
        public override void DataBind()
        {
            bind();
            if (_bound)
            {
                if (src != null && src != DBNull.Value && !String.IsNullOrWhiteSpace(src.ToString()))
                {
                    string temp = src.ToString();
                    switch (ImageType)
                    {
                    case ImageType.Thumb:
                        temp = CalendarManager.GetThumbImage(eventId, temp);
                        if (!StringUtils.IsNullOrWhiteSpace(temp))
                        {
                            this.Src = WebContext.Root + "/" + temp;
                        }
                        break;

                    case ImageType.Medium:
                        temp = CalendarManager.GetMediumImage(eventId, temp);
                        if (!StringUtils.IsNullOrWhiteSpace(temp))
                        {
                            this.Src = WebContext.Root + "/" + temp;
                        }
                        break;

                    case ImageType.Large:
                        temp = CalendarManager.GetLargeImage(eventId, temp);
                        if (!StringUtils.IsNullOrWhiteSpace(temp))
                        {
                            this.Src = WebContext.Root + "/" + temp;
                        }
                        break;

                    default:
                        temp = CalendarManager.GetImage(eventId, temp);
                        if (!StringUtils.IsNullOrWhiteSpace(temp))
                        {
                            this.Src = WebContext.Root + "/" + temp;
                        }
                        break;
                    }
                }
                else
                {
                    if (!String.IsNullOrWhiteSpace(NoImage))
                    {
                        this.Src = noImage;
                    }
                    else
                    {
                        this.Visible = false;
                    }
                }
                if (String.IsNullOrEmpty(this.Src))
                {
                    if (String.IsNullOrEmpty(NoImage))
                    {
                        Visible = false;
                        return;
                    }
                }

                if (LazyLoad)
                {
                    this.Attributes.Add("data-image", this.Src);
                    this.Attributes["class"] += " lazy-load";
                    this.Src = null;
                }

                this.Attributes["alt"] = alt != null?StringUtils.StripOutHtmlTags(alt.ToString()) : "";

                base.DataBind();
            }
        }