protected void Page_Load(object sender, EventArgs e)
        {
            // ensure the username is valid
            if (string.IsNullOrEmpty(Username))
            {
                return;
            }

            // retrieve contents
            var url        = string.Format(FEED_URL, Username, MaxTweets);
            var twitterXML = XDocument.Load(url);

            if (twitterXML == null)
            {
                return;
            }

            // parse to collection
            var query = from t in twitterXML.Descendants("item") select new { TweetID = ToGuid(t.Element("guid").Value), Tweet = ToHtml(t.Element("title").Value), TimeStamp = ToDate(t.Element("pubDate").Value), Url = t.Element("link").Value };

            // bind if not empty
            if (query.Count() == 0)
            {
                return;
            }

            // bind
            TwitterRepeater.DataSource = query;
            TwitterRepeater.DataBind();
        }
Example #2
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            EnsureChildControls();

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

            // bind twitter icon
            TwitterProfileIcon.ImageUrl = string.Format("http://img.tweetimag.es/i/{0}_m", Username);

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

            // bind logo
            TwitterLogo.ImageUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), TWITTER_LOGO_RESOURCE);

            // retrieve contents
            var url        = string.Format(FEED_URL, Username, MaxTweets);
            var twitterXML = XDocument.Load(url);

            if (twitterXML == null)
            {
                return;
            }

            // parse to collection
            var query = from t in twitterXML.Descendants("item") select new { TweetID = ExtractGuid(t.Element("guid").Value), Tweet = ToHtml(t.Element("title").Value), TimeStamp = ToDate(t.Element("pubDate").Value), Url = t.Element("link").Value };

            // bind if not empty
            if (query.Count() == 0)
            {
                return;
            }

            // bind
            TwitterRepeater.ItemDataBound += new RepeaterItemEventHandler(TwitterRepeater_ItemDataBound);
            TwitterRepeater.DataSource     = query;
            TwitterRepeater.DataBind();
        }