Exemple #1
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void Page_Load(object sender, System.EventArgs e)
        {
            _siteName = HttpUtility.HtmlEncode(ApplicationAdapter.GetSiteName());

            int forumID = HnDGeneralUtils.TryConvertToInt(Request.QueryString["ForumID"]);

            _forum = CacheManager.GetForum(forumID);
            if ((_forum != null) && _forum.HasRSSFeed)
            {
                _forumURL = "http://" + Request.Url.Host + ApplicationAdapter.GetVirtualRoot() + String.Format(@"Threads.aspx?ForumID={0}", forumID);

                // get the messages
                ForumMessagesTypedList messages = ForumGuiHelper.GetLastPostedMessagesInForum(10, forumID);
                rptRSS.DataSource = messages;
                rptRSS.DataBind();

                Response.Cache.SetExpires(DateTime.Now.AddDays(7));
                Response.Cache.SetCacheability(HttpCacheability.Public);
                Response.Cache.SetValidUntilExpires(true);
                Response.Cache.VaryByParams["ForumID"] = true;
                Response.Cache.AddValidationCallback(new HttpCacheValidateHandler(Validate), null);
            }
        }
Exemple #2
0
        protected void rptRSS_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            switch (e.Item.ItemType)
            {
            case ListItemType.AlternatingItem:
            case ListItemType.Item:
                DataRowView currentRow = (DataRowView)e.Item.DataItem;
                string      nickName   = currentRow["NickName"].ToString();
                string      message    = currentRow["MessageTextAsHTML"].ToString();
                string      subject    = currentRow["Subject"].ToString();
                Literal     title      = (Literal)e.Item.FindControl("title");
                title.Text = HttpUtility.HtmlEncode(String.Format("{0} by {1}", subject, nickName));

                Literal description = (Literal)e.Item.FindControl("description");
                description.Text = HttpUtility.HtmlEncode(message);

                Literal link           = (Literal)e.Item.FindControl("itemLink");
                int     threadID       = (int)currentRow["ThreadID"];
                int     messageID      = (int)currentRow["MessageID"];
                int     startAtMessage = ThreadGuiHelper.GetStartAtMessageForGivenMessageAndThread(threadID, messageID, ApplicationAdapter.GetMaxAmountMessagesPerPage());
                link.Text = HttpUtility.HtmlEncode("http://" + Request.Url.Host + ApplicationAdapter.GetVirtualRoot() + String.Format(@"Messages.aspx?ThreadID=" + threadID + "&StartAtMessage=" + startAtMessage + "#" + messageID));

                Literal permaLink = (Literal)e.Item.FindControl("permaLink");
                permaLink.Text = link.Text;

                Literal pubDate = (Literal)e.Item.FindControl("pubDate");
                pubDate.Text = String.Format("{0:R}", ((DateTime)currentRow["PostingDate"]).AddHours(-2));

                Literal author = (Literal)e.Item.FindControl("author");
                author.Text = nickName;

                Literal category = (Literal)e.Item.FindControl("threadName");
                category.Text = HttpUtility.HtmlEncode(subject);
                break;
            }
        }