コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // ensure the username is valid
            if (string.IsNullOrEmpty(UserID))
            {
                return;
            }

            // retrieve contents
            var url       = string.Format(FEED_URL, UserID);
            var flickrXml = XDocument.Load(url);

            if (flickrXml == null)
            {
                return;
            }

            // parse to collection
            XNamespace media = "http://search.yahoo.com/mrss/";
            var        query = from t in flickrXml.Descendants("item") select new { Thumbnail = t.Element(media + "thumbnail").Attribute("url").Value, Url = t.Element("link").Value, Title = t.Element("title").Value };

            // empty result?
            if (query.Count() == 0)
            {
                return;
            }

            // bind, limiting count
            FlickrRepeater.DataSource = query.Take(MaxPhotos);
            FlickrRepeater.DataBind();
        }
コード例 #2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            EnsureChildControls();

            // bind links
            HeaderLink.Text        = Username;
            HeaderLink.NavigateUrl = FooterLink.NavigateUrl = string.Concat("http://flickr.com/photos/", Username);

            // ensure the username is valid
            if (string.IsNullOrEmpty(UserID))
            {
                return;
            }

            // retrieve contents
            var url       = string.Format(FEED_URL, UserID);
            var flickrXml = XDocument.Load(url);

            if (flickrXml == null)
            {
                return;
            }

            // parse to collection
            XNamespace media = "http://search.yahoo.com/mrss/";
            var        query = from t in flickrXml.Descendants("item") select new { Thumbnail = t.Element(media + "thumbnail").Attribute("url").Value, Url = t.Element("link").Value, Title = t.Element("title").Value };

            // empty result?
            if (query.Count() == 0)
            {
                return;
            }

            // bind, limiting count
            FlickrRepeater.ItemDataBound += new RepeaterItemEventHandler(FlickrRepeater_ItemDataBound);
            FlickrRepeater.DataSource     = query.Take(MaxPhotos);
            FlickrRepeater.DataBind();
        }